Glo*_*tin 1 plsql oracle-sqldeveloper
我有一个带有多个游标的存储过程。它们被定义为 IN OUT 参数。我想使用 SQL Developer 显示游标的结果。这是存储过程的示例:
SET serveroutput on;
DECLARE
p_input_stream VARCHAR2(200);
p_msg_code NUMBER;
p_msg_parms VARCHAR2(200);
p_return_code NUMBER;
p_trailer_cur sl_globals.curtype_weak;
BEGIN
/* Assign values to IN parameters */
p_input_stream := '24954286Mnull|5155035|2|436|SCAN|47720|XTRA|0105||5155035||||N|~|\r';
p_trailer_cur := null;
EXEC TRAILER_INFO(p_input_stream,
p_msg_code, p_msg_parms, p_return_code,
p_trailer_cur)
/* Display OUT parameters */
dbms_output.put_line('p_msg_code: ' || p_msg_code);
dbms_output.put_line('p_msg_parms: ' || p_msg_parms);
dbms_output.put_line('p_return_code: ' || p_return_code);
Run Code Online (Sandbox Code Playgroud)
我尝试创建一个 refcursor 变量并使用它来代替p_trailer_cur这样
VARIABLE trailer_cur refcursor;
EXEC TRAILER_INFO(p_input_stream,
p_msg_code, p_msg_parms, p_return_code,
:trailer_cur)
print trailer_cur;
Run Code Online (Sandbox Code Playgroud)
我收到错误:
SP2-0552:绑定变量“trailer_cur 未声明。
该变量已声明,所以我不明白该错误。
SQL Developer 支持此功能的两种方式 - GUI 和代码。
图形用户界面
如果您从代码编辑器执行存储过程,请在树中找到该存储过程,单击它,使用“执行”按钮 - 我们将获取所有输出,并将其显示在输出面板中:
和你的尝试,代码:
如果您在 SQL 工作表中并且有匿名块,则可以使用 F5 运行它,包括打印命令。
就像这样——
create or replace function get_emps(dno in number) return sys_refcursor
is
return_value sys_refcursor;
begin
open return_value for
select * from employees where department_id = dno;
return return_value;
end;
/
var rc refcursor
exec :rc := get_emps(90)
print rc
Run Code Online (Sandbox Code Playgroud)