英文:
SP2-0625: Error printing variable SYS_REFCURSOR
问题
I suspect there is some issue with the cursor itself , because it all started when I got ORA-01001 Invalid Cursor.
英文:
This is a minimal example:
I suspect there is some issue with the cursor itself , because it all started when I got ORA-01001 Invalid Cursor
create or replace
package TABULA.gettorim as
PROCEDURE liorByBranch ( br_out_rec OUT sys_refcursor );
end gettorim;
/
Package created.
CREATE OR REPLACE PACKAGE BODY tabula.gettorim AS
PROCEDURE liorbybranch (
br_out_rec OUT SYS_REFCURSOR
) IS
BEGIN
EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-mm-yyyy''';
OPEN br_out_rec FOR
SELECT * FROM DUAL;
CLOSE br_out_rec;
END liorbybranch;
END gettorim;
/
Package body created.
SQL>
variable br_out_rec refcursor;
DECLARE
BEGIN
TABULA.gettorim.liorbybranch(:br_out_rec);
END;
/
print br_out_recSQL> 2 3 4 5
PL/SQL procedure successfully completed.
SQL>
ERROR:
ORA-24338: statement handle not executed
SP2-0625: Error printing variable "br_out_rec"
I suspect there is some issue with the cursor itself , because it all started when I got ORA-01001 Invalid Cursor
答案1
得分: 0
That's because you closed the cursor; don't do that.
SQL> CREATE OR REPLACE PROCEDURE liorbybranch (br_out_rec OUT SYS_REFCURSOR)
2 IS
3 BEGIN
4 EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-mm-yyyy''';
6 OPEN br_out_rec FOR SELECT * FROM DUAL;
8 -- CLOSE br_out_rec; --> here
9 END liorbybranch;
10 /
Procedure created.
SQL> var br_out_rec refcursor;
SQL> exec liorbybranch(:br_out_rec);
PL/SQL procedure successfully completed.
SQL> print br_out_rec
D
X
SQL>
英文:
That's because you closed the cursor; don't do that.
SQL> CREATE OR REPLACE PROCEDURE liorbybranch (br_out_rec OUT SYS_REFCURSOR)
2 IS
3 BEGIN
4 EXECUTE IMMEDIATE 'alter session set nls_date_format=''dd-mm-yyyy''';
5
6 OPEN br_out_rec FOR SELECT * FROM DUAL;
7
8 -- CLOSE br_out_rec; --> here
9 END liorbybranch;
10 /
Procedure created.
SQL> var br_out_rec refcursor;
SQL> exec liorbybranch(:br_out_rec);
PL/SQL procedure successfully completed.
SQL> print br_out_rec
D
-
X
SQL>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论