将您的程序创建为
CREATE OR REPLACE PROCEDURE get_cdr_rs_phone (
cdr_recordset OUT sys_refcursor
)
AS
BEGIN
OPEN cdr_recordset FOR
SELECT zkv.ciscocuic_tbl.fld_callingpartynumber
FROM zkv.ciscocuic_tbl;
END get_cdr_rs_phone;
/
并执行你的程序
variable r refcursor;
DECLARE
BEGIN
get_cdr_rs_phone (:r);
END;
/
print r
更新 1
如果您的过程仅执行选择,您可以使用返回 sys_refcursor 的函数来执行此操作,并且该函数可以从 sql 语句中执行。
创建函数为
CREATE OR REPLACE FUNCTION get_cdr_rs_phone_func
RETURN sys_refcursor
AS
out_cursor sys_refcursor;
BEGIN
OPEN out_cursor FOR
SELECT zkv.ciscocuic_tbl.fld_callingpartynumber
FROM zkv.ciscocuic_tbl;
END get_cdr_rs_phone;
RETURN out_cursor;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
--raise error
WHEN OTHERS
THEN
--raise error
END get_cdr_rs_phone_func;
/
并将此函数称为
select get_cdr_rs_phone_func from dual;