If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL Cursor Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-11, 11:36
ozzii ozzii is offline
Registered User
 
Join Date: Mar 2007
Posts: 194
MySQL Cursor Question

Hi,

I am used to declaring cursors as follows:

Code:
DECLARE cursor1 CURSOR FOR SELECT col1 FROM myTable;
I have a very large sql select statement stored as a stored procedure. Is it possible to declare a cursor and set its value from a stored procedure as follows:

Code:
DECLARE cursor2 CURSOR FOR CALL StoredProc(v_col1);
I dont want to re-write the entire select statement again if its already stored in a stored procedure - StoredProc(v_col1). However the above syntax throws an error. I cant find anything in the MySQL doc or online regarding this so I was wondering if any one here had any knowleged if this is possible.
Reply With Quote
  #2 (permalink)  
Old 09-19-11, 15:08
it-iss.com it-iss.com is offline
Registered User
 
Join Date: Sep 2009
Location: San Sebastian, Spain
Posts: 620
There is no direct way of passing the result set as you have put it above. However, you could use temporary tables which will store the result set from the first query and then you can reuse this same result set within the second stored procedure by accessing the temporary table.
__________________
Ronan Cashell
Senior Oracle/MySQL DBA
http://www.it-iss.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On