我正在
ORA-06550: line 2, column 1:
PLS-00306: wrong number or types of arguments in call to 'GET_EMP_RS'
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
在oracle中执行select命令存储过程时出错。我的程序是
CREATE OR REPLACE
PROCEDURE get_emp_rs (p_deptno IN emp.EMPNO%TYPE,
p_recordset OUT SYS_REFCURSOR) AS
BEGIN
OPEN p_recordset FOR
SELECT ENAME,
JOB,
MGR
FROM emp
WHERE EMPNO = p_deptno
ORDER BY ENAME;
END;
/
答案 0 :(得分:3)
您没有正确调用该程序。
在 SQL * Plus 中,您可以这样做:
SQL> CREATE OR REPLACE
2 PROCEDURE get_emp_rs(
3 p_deptno IN emp.DEPTNO%TYPE,
4 p_recordset OUT SYS_REFCURSOR)
5 AS
6 BEGIN
7 OPEN p_recordset FOR
8 SELECT ENAME, JOB, MGR
9 FROM emp
10 WHERE DEPTNO = p_deptno
11 ORDER BY ENAME;
12 END;
13 /
Procedure created.
SQL>
SQL> SHOW ERRORS
No errors.
SQL>
SQL> variable cur refcursor
SQL>
SQL> DECLARE
2 cur SYS_REFCURSOR;
3 BEGIN
4 get_emp_rs(10, :cur);
5 END;
6 /
PL/SQL procedure successfully completed.
SQL>
SQL> print cur;
ENAME JOB MGR
---------- --------- ----------
CLARK MANAGER 7839
KING PRESIDENT
MILLER CLERK 7782
SQL>
或者,
可以从 PL / SQL 引用为:
SQL> DECLARE
2 l_cursor SYS_REFCURSOR;
3 l_ename emp.ename%TYPE;
4 l_job emp.job%TYPE;
5 l_mgr emp.mgr%TYPE;
6 BEGIN
7 get_emp_rs (p_deptno => 10, p_recordset => l_cursor);
8 LOOP
9 FETCH l_cursor INTO l_ename, l_job, l_mgr;
10 EXIT
11 WHEN l_cursor%NOTFOUND;
12 DBMS_OUTPUT.PUT_LINE(l_ename || ' | ' || l_job || ' | ' || l_mgr);
13 END LOOP;
14 CLOSE l_cursor;
15 END;
16 /
CLARK | MANAGER | 7839
KING | PRESIDENT |
MILLER | CLERK | 7782
PL/SQL procedure successfully completed.
SQL>