Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-27250

Allow OPEN / FETCH on prepared statements

    XMLWordPrintable

Details

    • Task
    • Status: Open (View Workflow)
    • Critical
    • Resolution: Unresolved
    • None
    • Stored routines
    • None

    Description

      The only option for a prepared statement is currently to EXECUTE it. This feature is a request to be able to OPEN a stored procedure as a cursor and FETCH from it.

      delimiter //
      CREATE OR REPLACE PROCEDURE proc1(p1 INTEGER)
      BEGIN
         DECLARE done INT DEFAULT FALSE;
         DECLARE v1 INTEGER;
         DECLARE c1 CURSOR;
         DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
       
         PREPARE s1 FROM 'SELECT c1 FROM t1 WHERE c1 < ?';
         OPEN c1 FROM s1 USING p1;
         read_loop: LOOP
            FETCH c1 INTO v1;
            IF done THEN
                LEAVE read_loop;
            END IF;
            CALL proc1(v1);
         END LOOP;
         CLOSE c1;
      END;
      //
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            karlsson Anders Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.