plsql存储过程语法错误

时间:2014-12-10 16:54:01

标签: syntax plsql procedure

当我尝试以下代码时,我得到一个完成了0编译错误的过程..消息而不是过程成功完成消息。 这有什么问题?并帮助我纠正这个错误

CREATE OR REPLACE PROCEDURE omar_manager_report1 (
   pi_co_id          IN       VARCHAR2,                          -- Company ID
   pi_cntr_nbr       IN       NUMBER DEFAULT 0,
   -- if Contract number is passed then Case 1: will be executed
   pi_overdue_days   IN       NUMBER DEFAULT 0,
   --No of days related to Over due of application passed.
   po_var_ref        OUT      sys_refcursor
)
IS
   lv_query   VARCHAR2(400) ;
   lv_co_id   VARCHAR2 (200);
BEGIN
   lv_co_id := REPLACE (pi_co_id, ',', ''',''');
   --Default option for all group office
   lv_query :=
      'select distinct gue.co_id,
      (SELECT event_descp FROM get_event WHERE co_id = gue.co_id AND event_cd = gue.event_cd) AS event_desc
       FROM get_uwtg_event gue';
   DBMS_OUTPUT.put_line ('lv_query');

   OPEN po_var_ref FOR lv_query;
EXCEPTION
  WHEN OTHERS
  THEN
    DBMS_OUTPUT.put_line (SQLCODE);
END;
/

1 个答案:

答案 0 :(得分:0)

执行CREATE OR REPLACE PROCEDURE...语句编译该过程,但它不会调用该过程。您需要编写类似于以下内容的PL / SQL块来调用您的过程:

DECLARE
  csrOut   SYS_REFCURSOR;
BEGIN
  omar_manager_report1(pi_co_id        => '123456',
                       pi_cntr_nbr     => 0,
                       pi_overdue_days => 0,
                       po_var_ref      => csrOut);

  -- Add code here to fetch from csrOut and use the results appropriately

  -- Close the cursor opened by omar_manager_report1

  CLOSE csrOut;
EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Exception: ' || SQLCODE || ' : ' || SQLERRM);
END;

祝你好运。