oracle的存储过程如何返回结果集

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 *
               FROM tk_ticket;
       ELSE
          sqlstr :=
             ‘select *
            from tk_ticket where ticketcode=:w_id‘;
          OPEN p_rc FOR sqlstr USING p_id;
       END IF;
    END get;
END pkg_test;

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。