SQL存储过程编译错误:调用中的参数数量或类型错误

时间:2011-06-13 15:53:00

标签: sql oracle stored-procedures

我创建了这个存储过程。但是我收到了这个错误

  

ORA-06550:第14行第3列:PLS-00306:   错误的参数数量或类型   什么时候打电话给'CHALLENGEUPDATE'   传递的值是CUSTID   :='400800500'; POLICYNAME:=   '政策';挑战:=   'CHALLENGEID1'; PINPOSITIONS:=   'PINPOS';

代码是:

create or replace
procedure ChallengeUpdate  
(
   CustID        IN   SEC_CHALLENGE.CUSTOMERID%TYPE,
   PolicyName      IN   SEC_CHALLENGE.POLICY_NAME%TYPE,
   ChallengeId       IN   SEC_CHALLENGE.CHALLENGE_ID%TYPE,
   PinPositions       IN   SEC_CHALLENGE.PINPOSITIONS%TYPE,
   o_result   OUT  INTEGER,
   o_code OUT INTEGER,
   o_c OUT INTEGER
)
as
        c integer;
    begin
        select count(*) into c  from SEC_CHALLENGE xyz where xyz.CUSTOMERID=CustID and 
            xyz.POLICY_NAME=PolicyName;

        if c = 0 then
           INSERT INTO SEC_CHALLENGE(CUSTOMERID,CHALLENGE_ID,PINPOSITIONS,POLICY_NAME)
            VALUES (CustID,ChallengeId, PinPositions, PolicyName);

        else
            UPDATE RBSSEC_CHALLENGE 
            SET CHALLENGE_ID=ChallengeId, PINPOSITIONS=PinPositions
            WHERE CUSTOMERID=CustID and POLICY_NAME = PolicyName;
        end if;
        commit;
        o_result:=0;
        o_c:=c;
        exception when others then 
        o_result:=-1; 
        o_c:=c;
        rollback;
        o_code :=SQLCODE;
    end ChallengeUpdate;

SEC_CHALLENGE表是这个

CREATE TABLE "MUJEEB"."RBSSEC_CHALLENGE"
  (
    "CUSTOMERID"   VARCHAR2(9 BYTE) NOT NULL ENABLE,
    "CHALLENGE_ID" VARCHAR2(50 BYTE),
    "PINPOSITIONS" VARCHAR2(20 BYTE) NOT NULL ENABLE,
    "POLICY_NAME"  VARCHAR2(50 BYTE) NOT NULL ENABLE,
    CONSTRAINT "RBSSEC_CHALLENGE1_PK" PRIMARY KEY ("CHALLENGE_ID")
)

这是我如何运行它:

DECLARE CUSTID VARCHAR2(9); 
        POLICYNAME VARCHAR2(50); 
        CHALLENGEID VARCHAR2(50); 
        PINPOSITIONS VARCHAR2(20); 
        O_RESULT NUMBER; 
        O_CODE NUMBER; 
BEGIN   CUSTID :='400800500' ; 
        POLICYNAME := 'POLICY'; 
        CHALLENGEID := 'CHALLENGEID1'; 
        PINPOSITIONS := 'PINPOS'; 
        CHALLENGEUPDATE( CUSTID => CUSTID, POLICYNAME => POLICYNAME, CHALLENGEID => CHALLENGEID, PINPOSITIONS => PINPOSITIONS, O_RESULT => O_RESULT, O_CODE => O_CODE ); 
        DBMS_OUTPUT.PUT_LINE('O_RESULT = ' || O_RESULT); 
        DBMS_OUTPUT.PUT_LINE('O_CODE = ' || O_CODE); 
END;

3 个答案:

答案 0 :(得分:3)

如果使用以“out”关键字标记的输出参数,则必须为该参数传递变量。输出参数不是可选的。从错误中,我知道你还没有这样做。

答案 1 :(得分:2)

如果您使用的是toad,请尝试这种方式:

var o_result integer;
var ocode integer;
var oc integer;
exec ChallengeUpdate  ('400800500', 'POLICY', 'CHALLENGEID1', 'PINPOS', :o_result, :ocode, :oc  );
print o_result;
print ocode ;
print oc;

答案 2 :(得分:0)

来自宣言:

display: block

您对<g>的来电碰巧错过procedure ChallengeUpdate ( CustID IN SEC_CHALLENGE.CUSTOMERID%TYPE, PolicyName IN SEC_CHALLENGE.POLICY_NAME%TYPE, ChallengeId IN SEC_CHALLENGE.CHALLENGE_ID%TYPE, PinPositions IN SEC_CHALLENGE.PINPOSITIONS%TYPE, o_result OUT INTEGER, o_code OUT INTEGER, o_c OUT INTEGER ) as 的输出变量。你可以尝试下面的文字:

CHALLENGEUPDATE