Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong number or types of arguments in call to my procedure

hi I wrote this code to create a procedure to return a Boolean value based on the if conditions but when I execute it I got this error:

ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'DDPAY_SP'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

here is my procedure

create or replace procedure  DDPAY_SP (

donor_id dd_donor.iddonor%type,
pldgstatus out dd_pledge.idstatus%type,
monthplan  out dd_pledge.paymonths%type,
ret out boolean)
IS
begin

select idstatus, paymonths into
pldgstatus, monthplan from dd_pledge 
where iddonor = donor_id ;

if (pldgstatus = 10 AND monthplan >0)
then ret:= true;
else
ret:= false;
end if;

end;

and this how I execute it

 EXECUTE DDPAY_SP (308);

I didn't put much talk I hope it's clear enough for you

I read online it recommends me to check the naming also the data type which I did but nothing change

any ideas

like image 442
user2396035 Avatar asked May 24 '13 14:05

user2396035


1 Answers

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.

like image 151


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!