wrong number or types of arguments in call to my procedure

不羁岁月 提交于 2019-12-06 01:36:37

If you don't need the second and third arguments you could declare those as variables in the procedure instead of arguments, as follows:

CREATE OR REPLACE PROCEDURE DDPAY_SP(DONOR_ID IN  DD_DONOR.IDDONOR%TYPE,
                                     RET      OUT BOOLEAN)
IS
  nPayment_count  NUMBER;
BEGIN 
  SELECT COUNT(*)
    INTO nPayment_count  
    FROM DD_PLEDGE p
    WHERE p.IDDONOR = DONOR_ID AND
          p.IDSTATUS = 10 AND
          p.PAYMONTHS > 0;

  IF nPayment_count > 0 THEN
    RET := TRUE;
  END IF;
EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('DD_PAY - exception: ' || SQLCODE || ' : ' || SQLERRM);
    RAISE;
END DDPAY_SP;

I've included an example of an EXCEPTION handler at the end of DD_PAY. It's always a good idea to include at least this minimal handler so that in the event an exception occurs you'll get some indication of where the problem lies.

Because this procedure returns a BOOLEAN value, and BOOLEANs cannot (to the best of my knowledge) be used from SQL*Plus, you'll have to invoke it from a PL/SQL block, as follows:

DECLARE
  bRetval  BOOLEAN;
BEGIN
  DD_PAY(308, bRetval);
  DBMS_OUTPUT.PUT_LINE('Returned value is ' ||
                       CASE bRetval
                         WHEN TRUE THEN 'TRUE'
                         ELSE 'FALSE'
                       END);
END;

Give that a try.

EDIT: rewrote procedure based on further information from later comments.

Share and enjoy.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!