create or replace package types
as
type currtype is ref cursor;
end;
/
create or replace function hm1(v_deptno in number) return types.currtype
AS
test_cursor types.currtype;
sql_string VARCHAR2(500);
BEGIN
sql_string := 'SELECT empno, ename, sal FROM EMP WHERE DEPTNO = '|| v_deptno;
OPEN test_cursor FOR sql_string ;
RETURN test_cursor;
CLOSE test_cursor;
END;
variable a refcursor
exec :a := hm1(10)
print a
EMPNO ENAME SAL
---------- ---------- ----------
7782 CLARK 2450
7839 KING 5000
7934 MILLER 1300
as
type currtype is ref cursor;
end;
/
create or replace function hm1(v_deptno in number) return types.currtype
AS
test_cursor types.currtype;
sql_string VARCHAR2(500);
BEGIN
sql_string := 'SELECT empno, ename, sal FROM EMP WHERE DEPTNO = '|| v_deptno;
OPEN test_cursor FOR sql_string ;
RETURN test_cursor;
CLOSE test_cursor;
END;
variable a refcursor
exec :a := hm1(10)
print a
EMPNO ENAME SAL
---------- ---------- ----------
7782 CLARK 2450
7839 KING 5000
7934 MILLER 1300
댓글 없음:
댓글 쓰기