本文介绍了如何使用PLSQLDeveloper窗口打印SYS_REFCURSOR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的查询中,如何在PL/SQL的"SQL窗口"中获取IO_CURSOR值
In the below query how to get IO_CURSOR values in PL/SQL's "SQL Window"
DECLARE
SOME_VAR_1 VARCHAR2(20);
SOME_VAR_2 VARCHAR2(20);
SOME_VAR_3 DECIMAL;
IO_CURSOR SYS_REFCURSOR;
BEGIN
SOME_VAR_1 := 'test1';
SOME_VAR_2 := 'test2';
SOME_VAR_3 := 1;
IO_CURSOR := NULL;
Get_Analysis_Data(p_in_symbol_type => SOME_VAR_1,
p_in_symbol => SOME_VAR_2,
p_in_isr_id => SOME_VAR_3,
isr_main_view => IO_CURSOR);
PRINT IO_CURSOR
END;
推荐答案
如果通过"SQL窗口"表示SQL * PLUS,然后打印(使用PRINT
命令)游标的内容,则需要声明一个在PL/SQL块外部绑定变量,通过执行该块为PL/SQL块内部绑定变量赋值,然后使用PRINT
命令打印内容:
If by "SQL Window" you mean SQL*PLUS ,then to print(using PRINT
command) the contents of a cursor, you need to declare a bind variable outside the PL/SQL block, assign a value to that bind variable inside the PL/SQL block by executing the block and then print the contents by using PRINT
command:
SQL> variable IO_CURSOR refcursor;
SQL> DECLARE
2 SOME_VAR_1 VARCHAR2(20);
3 SOME_VAR_2 VARCHAR2(20);
4 SOME_VAR_3 DECIMAL;
5 --IO_CURSOR SYS_REFCURSOR;
6 BEGIN
7 SOME_VAR_1 := 'test1';
8 SOME_VAR_2 := 'test2';
9 SOME_VAR_3 := 1;
10 --IO_CURSOR := NULL; -- no need to do that
11 Get_Analysis_Data(p_in_symbol_type => SOME_VAR_1,
12 p_in_symbol => SOME_VAR_2,
13 p_in_isr_id => SOME_VAR_3,
14 isr_main_view => :IO_CURSOR);
15 END;
16 /
SQL> print io_cursor;
编辑:
要查看PL/SQL Developer中游标的内容(作为选项之一),只需执行以下操作:
To see the contents of a cursor in PL/SQL Developer, as one of the options, you could simply do the following:
- 文件\新建\测试"窗口
- 在此处复制/粘贴您的匿名PL/SQL块.在此之前,请删除
IO_CURSOR SYS_REFCURSOR;
变量声明.不需要它.同时将isr_main_view => IO_CURSOR
更改为isr_main_view => :IO_CURSOR
.在这种情况下,您需要使用绑定变量. - 在
test window
底部的variables window
中,指定您要查看其内容的ref游标的变量名称(IO_CURSOR
不带分号),然后选择类型cursor
. - 按绿色三角形执行该块.
- 执行PL/SQL块后,请参考
variables window
的列value
.按下带有省略号的按钮以查看参考光标IO_CURSOR
的内容.
- File\New\Test window
- Copy/Paste your anonymous PL/SQL block there. Prior to this remove
IO_CURSOR SYS_REFCURSOR;
variable declaration. There is no need of it. Also changeisr_main_view => IO_CURSOR
toisr_main_view => :IO_CURSOR
. You need to use bind variable in this case. - In the
variables window
at the bottom of thetest window
specify variable name of your ref cursor the contents of which you want to see (IO_CURSOR
without preceding semicolon ) and select typecursor
. - Execute the block by pressing green triangle.
- After PL/SQL block is executed refer to the column
value
of thevariables window
. Press the button with ellipsis on it to see the contents of the ref cursorIO_CURSOR
.
这篇关于如何使用PLSQLDeveloper窗口打印SYS_REFCURSOR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!