Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2007

    Unanswered: MySQL Cursor Question


    I am used to declaring cursors as follows:

    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.

  2. #2
    Join Date
    Sep 2009
    San Sebastian, Spain
    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
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    Follow me on Twitter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts