使用游标和 out 参数调用存储过程
calling stored procedure with cursor and out parameter
我有以下存储过程
CREATE OR Replace PROCEDURE sprocvPOP_GetvemployeeByFilter
(TheFilter varchar2,
TheOrder varchar2,
PageOrder int,
ItemsPerPage int,
TheCount out number,
cur out sys_refcursor)as
begin
........
end
我想调用这个过程,并打印 cur 参数和 count 参数值,因为它们是输出变量。
我尝试在 SQL Developer
中使用以下语法
set serveroutput on
var rc refcursor;
declare
mycount number(19);
begin
execute sprocvPOP_GetvemployeeByFilter (NULL,NULL,1,10,mycount,:rc);
print rc;
dbms_output.put_line(mycount);
end;
但我得到了错误
PLS-00103: Encountered the symbol "RC" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "RC" to continue.
如何在 SQL Developer 中执行此过程并打印出参数?
为了回答你原来的问题,print rc
是一个 SQL*Plus 命令,所以它需要在 PL/SQL 块之外。 execute
也是一个 SQL*Plus 命令,不用于 PL/SQL。所以你的代码应该是这样的:
set serveroutput on
var rc refcursor;
declare
mycount number(19);
begin
sprocvPOP_GetvemployeeByFilter (NULL,NULL,1,10,mycount,:rc);
dbms_output.put_line(mycount);
end;
/
print rc;
但是,事实证明您使用的是 SQL 开发人员而不是 SQL*Plus 客户端 运行 您的代码。 SQL*Plus 命令在 SQL Developer 中不受原生支持。 The list is here.
该工具的最新版本带有非常简洁的命令行界面。 Find out more。
或者,使用 运行 PL/SQL 中描述的内置功能 in this tutorial
我有以下存储过程
CREATE OR Replace PROCEDURE sprocvPOP_GetvemployeeByFilter
(TheFilter varchar2,
TheOrder varchar2,
PageOrder int,
ItemsPerPage int,
TheCount out number,
cur out sys_refcursor)as
begin
........
end
我想调用这个过程,并打印 cur 参数和 count 参数值,因为它们是输出变量。
我尝试在 SQL Developer
中使用以下语法set serveroutput on
var rc refcursor;
declare
mycount number(19);
begin
execute sprocvPOP_GetvemployeeByFilter (NULL,NULL,1,10,mycount,:rc);
print rc;
dbms_output.put_line(mycount);
end;
但我得到了错误
PLS-00103: Encountered the symbol "RC" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "RC" to continue.
如何在 SQL Developer 中执行此过程并打印出参数?
为了回答你原来的问题,print rc
是一个 SQL*Plus 命令,所以它需要在 PL/SQL 块之外。 execute
也是一个 SQL*Plus 命令,不用于 PL/SQL。所以你的代码应该是这样的:
set serveroutput on
var rc refcursor;
declare
mycount number(19);
begin
sprocvPOP_GetvemployeeByFilter (NULL,NULL,1,10,mycount,:rc);
dbms_output.put_line(mycount);
end;
/
print rc;
但是,事实证明您使用的是 SQL 开发人员而不是 SQL*Plus 客户端 运行 您的代码。 SQL*Plus 命令在 SQL Developer 中不受原生支持。 The list is here.
该工具的最新版本带有非常简洁的命令行界面。 Find out more。
或者,使用 运行 PL/SQL 中描述的内置功能 in this tutorial