如何使用PLSQLDeveloper窗口打印SYS_REFCURSOR? [英] How to print SYS_REFCURSOR with PLSQLDeveloper window?

查看:346
本文介绍了如何使用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:

  1. 文件\新建\测试"窗口
  2. 在此处复制/粘贴您的匿名PL/SQL块.在此之前,请删除IO_CURSOR SYS_REFCURSOR;变量声明.不需要它.同时将isr_main_view => IO_CURSOR更改为isr_main_view => :IO_CURSOR.在这种情况下,您需要使用绑定变量.
  3. test window底部的variables window中,指定您要查看其内容的ref游标的变量名称(IO_CURSOR不带分号),然后选择类型cursor.
  4. 按绿色三角形执行该块.
  5. 执行PL/SQL块后,请参考variables window的列value.按下带有省略号的按钮以查看参考光标IO_CURSOR的内容.
  1. File\New\Test window
  2. 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 change isr_main_view => IO_CURSOR to isr_main_view => :IO_CURSOR. You need to use bind variable in this case.
  3. In the variables window at the bottom of the test window specify variable name of your ref cursor the contents of which you want to see (IO_CURSOR without preceding semicolon ) and select type cursor.
  4. Execute the block by pressing green triangle.
  5. After PL/SQL block is executed refer to the column value of the variables window. Press the button with ellipsis on it to see the contents of the ref cursor IO_CURSOR.

这篇关于如何使用PLSQLDeveloper窗口打印SYS_REFCURSOR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆