oracle 如何在oracle sql developer中运行存储过程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20186588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run a stored procedure in oracle sql developer?
提问by Samy Louize Hanna
I'm trying to run this stored procedure
我正在尝试运行这个存储过程
DECLARE
P_TICKER_SERIAL VARCHAR2(200);
P_SECTOR_CODE VARCHAR2(200);
P_SOURCE_ID VARCHAR2(200);
P_COUNTRY_CODE VARCHAR2(200);
P_FILTER_TYPE NUMBER;
CUR_OUT SYS_REFCURSOR;
dbUserTable DBUSER%ROWTYPE;
BEGIN
P_TICKER_SERIAL :='14232';
P_SECTOR_CODE := '15';
P_SOURCE_ID := 'TDWL';
P_COUNTRY_CODE := 'SA';
P_FILTER_TYPE := 1;
PKG_name.GET_user(
P_TICKER_SERIAL => P_TICKER_SERIAL,
P_SECTOR_CODE => P_SECTOR_CODE,
P_SOURCE_ID => P_SOURCE_ID,
P_COUNTRY_CODE => P_COUNTRY_CODE,
P_FILTER_TYPE => P_FILTER_TYPE,
CUR_OUT => CUR_OUT
);
open CUR_OUT;
LOOP
FETCH CUR_OUT INTO dbUserTable;
dbms_output.put_line(dbUserTable.email);
END LOOP;
CLOSE CUR_OUT;
END;
/
But it gives me this error
但它给了我这个错误
Error report:
ORA-06550: line 8, column 15:
PLS-00201: identifier 'DBUSER' must be declared
ORA-06550: line 8, column 15:
PL/SQL: Item ignored
ORA-06550: line 24, column 2:
PLS-00382: expression is of wrong type
ORA-06550: line 24, column 2:
PL/SQL: SQL Statement ignored
ORA-06550: line 26, column 24:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 26, column 5:
PL/SQL: SQL Statement ignored
ORA-06550: line 27, column 28:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 27, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Any one knows what is wrong ? Thanks.
有谁知道出了什么问题?谢谢。
回答by Dba
Try to execute the procedure like this,
尝试执行这样的程序,
var c refcursor;
execute pkg_name.get_user('14232', '15', 'TDWL', 'SA', 1, :c);
print c;
回答by Mohanraj Balasubramaniam
Consider you've created a procedure like below.
假设您已经创建了一个如下所示的过程。
CREATE OR REPLACE PROCEDURE GET_FULL_NAME like
(
FIRST_NAME IN VARCHAR2,
LAST_NAME IN VARCHAR2,
FULL_NAME OUT VARCHAR2
) IS
BEGIN
FULL_NAME:= FIRST_NAME || ' ' || LAST_NAME;
END GET_FULL_NAME;
In Oracle SQL Developer, you can run this procedure in two ways.
在 Oracle SQL Developer 中,您可以通过两种方式运行此过程。
1. Using SQL Worksheet
1. 使用 SQL 工作表
Create a SQL Worksheet and write PL/SQL anonymous block like this and hit f5
创建一个 SQL 工作表并像这样编写 PL/SQL 匿名块并按 f5
DECLARE
FULL_NAME Varchar2(50);
BEGIN
GET_FULL_NAME('Foo', 'Bar', FULL_NAME);
Dbms_Output.Put_Line('Full name is: ' || FULL_NAME);
END;
2. Using GUI Controls
2. 使用 GUI 控件
Expand Procedures
Right click on the procudure you've created and Click Run
In the pop-up window, Fill the parameters and Click OK.
展开程序
右键单击您创建的程序,然后单击运行
在弹出窗口中,填写参数并单击确定。
Cheers!
干杯!
回答by Ania
-- If no parameters need to be passed to a procedure, simply:
-- 如果不需要向过程传递参数,只需:
BEGIN
MY_PACKAGE_NAME.MY_PROCEDURE_NAME
END;