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:
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.
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.