Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 18th, 2008, 07:49 AM
Newbie
 
Join Date: Aug 2008
Posts: 4
Default how to insert data by calling procedure

Hi all,
as part of my project requirement we are migrating procedures from mssql to mysql
below is the code in mssql
Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE TABLE_DEPEND_INSERT_ORDER
  2. AS
  3.   CREATE TABLE #TABLE_DEPEND_ORDER_SUMMARY (
  4.     TABLE_NAME varchar(128),
  5.     SORT_ORDER int
  6.   )
  7.   INSERT INTO #TABLE_DEPEND_ORDER_SUMMARY EXEC TABLE_DEPEND_ORDER 'F'
  8.   SELECT TABLE_NAME FROM #TABLE_DEPEND_ORDER_SUMMARY ORDER BY SORT_ORDER DESC;
  9.  
how can i insert data by calling the stored procedure as above.
please do the need full.
Regards,
Vijaya

Last edited by Atli; August 18th, 2008 at 11:01 PM. Reason: Added [code] tags
Reply
  #2  
Old August 18th, 2008, 11:12 PM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Age: 22
Posts: 2,777
Default

Hi.

What is it that you are trying to do there? (I don't speak Microsoft)

What have you tried so far?
Why / how isn't it working?
Got any errors that may help find the problem?

We are happy to help you solve problems with your code, but we will not write it for you.

Also.
Please post your code examples inside [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.

MODERATOR.
Reply
  #3  
Old August 19th, 2008, 08:39 AM
Newbie
 
Join Date: Aug 2008
Posts: 4
Default

Hi, here is the procedure i created in mysql as replacement of the above mssql one.
Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE TABLE_DEPEND_INSERT_ORDER()
  2. begin
  3.   CREATE TEMPORARY TABLE TABLE_DEPEND_ORDER_SUMMARY (
  4.     TABLE_NAME varchar(128),
  5.     SORT_ORDER int
  6.   );
  7.   INSERT INTO TABLE_DEPEND_ORDER_SUMMARY call TABLE_DEPEND_ORDER ('T','F')
  8.   SELECT TABLE_NAME FROM TABLE_DEPEND_ORDER_SUMMARY ORDER BY SORT_ORDER DESC;
  9.   end
  10.  
when i compile this code it is giving me the below error message
Expand|Select|Wrap|Line Numbers
  1. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'call TABLE_DEPEND_ORDER ('T','F')
  2.   SELECT TABLE_NAME FROM TABLE_DEPEND_ORDER_S' at line 7
  3.  
please provide me solution

Regards,
vijaya

Last edited by Atli; August 19th, 2008 at 10:57 AM. Reason: Added [code] tags.
Reply
  #4  
Old August 19th, 2008, 11:12 AM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Age: 22
Posts: 2,777
Default

vijaya.

I tried asking you nicely. Now I am telling you:
Use [code] tags when posting your code examples.

Following the Posting Guideliens is not optional, and failing to do so will get you banned from these forums.

I would prefer not to have to do that, so please read the guideliens and follow them in the future.

MODERATOR
Reply
  #5  
Old August 19th, 2008, 11:35 AM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Age: 22
Posts: 2,777
Default

As to your code.

You can not call a procedure in the middle of an INSERT statement.
Procedures dont' technically return a value, although they can be used to display the result of a SELECT.

Not knowing what this "TABLE_DEPEND_ORDER" procedure does, I would suggest trying to fuse the two procedures together.

That is; try to use the INSERT INTO table SELECT syntax, like:
Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tempTable SELECT * FROM realTable;
  2.  
You won't be able to just copy/past the MSSQL syntax into MySQL, even if you replace the keywords, as you did.
The way in which they implement procedures is very different. You will probably have to re-design a lot of them to fit them into MySQL's implementation.
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles