create or replace procedure ETIME.getallemployee
as
begin
select * from etime.employee;
end;
是想通过这个存储过程获取所有的employee信息。但是这个在oracle里面是有错的。
我也知道需要into,应该怎么样写才能把所有的信息返回来呢?
谢谢
...全文
266打赏收藏
存储过程的问题(在线等待)
我写了一个存储过程: create or replace procedure ETIME.getallemployee as begin select * from etime.employee; end; 是想通过这个存储过程获取所有的employee信息。但是这个在oracle里面是有错的。 我也知道需要into,应该怎么样写才能把所有的信息返回来呢? 谢谢
CREATE OR REPLACE package pkg_test as
type myrctype is ref cursor;
function get return myrctype;
end pkg_test;
/
CREATE OR REPLACE package body pkg_test as
function get return myrctype is
rc myrctype; --定义ref cursor变量
begin
open rc for select * from etime.employee;
return rc;
end get;
end pkg_test;
/
CREATE OR REPLACE PACKAGE pkg_test
AS
TYPE myrctype IS REF CURSOR;
PROCEDURE get (p_id NUMBER, p_rc OUT myrctype);
END pkg_test;
/
CREATE OR REPLACE PACKAGE BODY pkg_test
AS
PROCEDURE get (p_id NUMBER, p_rc OUT myrctype)
IS
sqlstr VARCHAR2 (500);
BEGIN
IF p_id = 0 THEN
OPEN p_rc FOR
SELECT ID, NAME, sex, address, postcode, birthday
FROM student;
ELSE
sqlstr :=
'select id,name,sex,address,postcode,birthday
from student where id=:w_id';
OPEN p_rc FOR sqlstr USING p_id;
END IF;
END get;
END pkg_test;
/