我的程序调用中参数的数量或类型错误 [英] wrong number or types of arguments in call to my procedure
问题描述
我编写了这段代码来创建一个过程,该过程根据if条件返回一个布尔值,但是当我执行它时,出现了这个错误:
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:
这是我的程序
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;
这就是我的执行方式
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
任何想法
推荐答案
如果不需要第二个和第三个参数,则可以在过程中将它们声明为变量而不是参数,如下所示:
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;
我在DD_PAY的末尾包含了EXCEPTION处理程序的示例.至少包括此最小处理程序始终是一个好主意,以便在发生异常的情况下,您可以了解问题的根源.
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.
由于此过程返回一个BOOLEAN值,并且(据我所知)不能从SQL * Plus中使用BOOLEAN,因此必须从PL/SQL块中调用它,如下所示:
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;
尝试一下.
根据以后的评论中的更多信息重写程序.
rewrote procedure based on further information from later comments.
分享并享受.
这篇关于我的程序调用中参数的数量或类型错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!