Details
-
New Feature
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
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 - will be added later
TYPE weak_cursor IS REF CURSOR; -- weak type - will be added later
- Dynamic SQL with SYS_REFCURSOR we'll implemeted under terms of a separate task MDEV-33830
DECLARE
c SYS_REFCURSOR;
str1 VARCHAR2(200):= 'SELECT * FROM t1 WHERE a=:id';
id INT:= 1;
BEGIN
OPEN c FOR str1 USING id;
END;
/
Attachments
Issue Links
- blocks
-
MDEV-34323 Oracle compatibility project 3
-
- Open
-
-
MDEV-34569 Oracle compatibility project 4
-
- Open
-
- causes
-
MDEV-36377 Assertion `thd->lex == sp_instr_lex' failed in LEX *sp_lex_instr::parse_expr(THD *, sp_head *, LEX *)
-
- Closed
-
-
MDEV-36409 Server crashes when creating a table using function with a return type sys_refcursor
-
- Closed
-
- is blocked by
-
MDEV-36047 Package body variables are not allowed as FETCH targets
-
- Closed
-
- is part of
-
MDEV-35973 Oracle Compatibility Project 1 for 2025
-
- In Progress
-
- relates to
-
MDEV-31661 Assertion `thd->lex == sp_instr_lex' failed in LEX* sp_lex_instr::parse_expr(THD*, sp_head*, LEX*)
-
- Closed
-
-
MDEV-36079 Stored routine with a cursor crashes on the second execution if a DDL statement happened
-
- Closed
-
-
MDEV-36081 CURSOR is not allowed in the top level block in PACKAGE BODY
-
- Closed
-
-
MDEV-36114 Assertion `(mem_root->flags & 4) == 0' failed in Field_iterator_table::create_item
-
- Closed
-
-
MDEV-36390 Minor refactoring of the method get_expr_query at the classes sp_instr_cpush/sp_instr_cursor_copy_struct
-
- Closed
-
-
MDEV-36642 Bad IS NULL result on an expression containing a ROW SP variable
-
- Open
-
-
MDEV-10152 Add support for TYPE .. IS REF CURSOR
-
- Open
-
-
MDEV-33830 Support for cursors on prepared statements
-
- Open
-
-
MDEV-35979 Oracle: Cursor expressions
-
- Open
-
-
MDEV-36053 CURSOR declarations in PACKAGE BODY
-
- In Progress
-
-
MDEV-36462 Crash on `DECLARE spvar1 ROW TYPE OF cursor1` after a table recreation
-
- Closed
-
I've limited:
They don't duplicate each other any more.