用游标输出,看看错在哪? 该函数功能是这样的:当输入一个部门编号时,输出该部门的员工的所有信息。(oracle自带scott用户下的emp表) create or replace function c_re(v_deptno in emp.deptno%type) return c_cursor is c_cursor cursor; cursor c_cursor is select * from emp where deptno=v_deptno; v_emp c_cursor%rowtype; begin open c_cursor; fetch c_cursor into v_emp; return v_emp; close c_cursor; end; 编译后第一行报错为:1 PLS-00320:此表达式的类型声明不完整或格式不正确,请好手指点。怎么改正?或写出你的函数也行
Sql代码 CREATE OR REPLACE PROCEDURE sp_test ( p_outstr OUT VARCHAR2 ,p_outint OUT NUMBER ,p_ref1 OUT SYS_REFCURSOR ,p_ref2 OUT SYS_REFCURSOR ) AS BEGIN p_outstr := 'abc'; p_outint := '56789'; OPEN p_ref1 FOR SELECT ROWNUM*2 AS RN FROM DUAL CONNECT BY ROWNUM<=10; OPEN p_ref2 FOR SELECT ROWNUM*2+1 AS RN FROM DUAL CONNECT BY ROWNUM<=10;
END sp_test;
/
过程已创建。
CREATE OR REPLACE PROCEDURE sp_test ( p_outstr OUT VARCHAR2 ,p_outint OUT NUMBER ,p_ref1 OUT SYS_REFCURSOR ,p_ref2 OUT SYS_REFCURSOR ) AS BEGIN p_outstr := 'abc'; p_outint := '56789'; OPEN p_ref1 FOR SELECT ROWNUM*2 AS RN FROM DUAL CONNECT BY ROWNUM<=10; OPEN p_ref2 FOR SELECT ROWNUM*2+1 AS RN FROM DUAL CONNECT BY ROWNUM<=10;
END sp_test;
/
过程已创建。
利用print客户端打印,sqlplus下:
Sql代码 SET AUTOPRINT ON VAR p_outstr VARCHAR2(10); VAR p_outint NUMBER; VAR p_ref1 REFCURSOR; VAR p_ref2 REFCURSOR;
SET AUTOPRINT ON VAR p_outstr VARCHAR2(10); VAR p_outint NUMBER; VAR p_ref1 REFCURSOR; VAR p_ref2 REFCURSOR;