Details

    • Technical task
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None

    Description

      CREATE OR REPLACE FUNCTION|PROCEDURE does not support RETURN REFCURSOR|SYS_REFCURSOR

      Oracle Doc: https://docs.oracle.com/database/121/LNPLS/cursor_variable.htm#LNPLS01312

      Under terms of this task we'll add support for weak cursor variables of the pre-defined SYS_REFCURSOR type.

      Example:

      DECLARE
        c SYS_REFCURSOR;
        a INT;
      BEGIN
        OPEN c FOR SELECT 1 FROM DUAL;
        FETCH c INTO a;
        CLOSE c;
        dbms_output.put_line(a); 
      END;
      /
      

      It will be possible to return a cursor in an OUT stored procedure parameter or as a function RETURN value:

      CREATE TABLE t1 (a INT);
      INSERT INTO t1 VALUES (10),(20);
       
      CREATE FUNCTION f1 RETURN SYS_REFCURSOR AS
        c SYS_REFCURSOR;
      BEGIN
        OPEN c FOR SELECT a FROM t1 ORDER BY a;
        RETURN c;
      END;
      /
       
      CREATE PROCEDURE p1 AS
        a INT;
        c SYS_REFCURSOR DEFAULT f1();
      BEGIN
        LOOP
          FETCH c INTO a;
          EXIT WHEN c%NOTFOUND;
          dbms_output.put_line(a);
        END LOOP;
        CLOSE c;
      END;
      /
       
      CALL p1();
      

      10
      20
      

      Features out of scope of this task

      Cursor TYPE definitions (even weak ones) we'll be implemented under terms of a separate task MDEV-10152:

      DECLARE
        TYPE storong_cursor IS REF CURSOR RETURN employees%ROWTYPE;  -- strong type - we'll be added later
        TYPE weak_cursor IS REF CURSOR;                              -- weak type - we'll be added later
      

      Attachments

        Issue Links

          Activity

            People

              bar Alexander Barkov
              Faisal Faisal Saeed (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.