I have created this stored procedure. However I get this error
ORA-06550:line 14 column 3: PLS-00306: wrong number or types of arguments in call to 'CHALLENGEUPDATE' when the values passed are CUSTID :='400800500' ; POLICYNAME := 'POLICY'; CHALLENGEID := 'CHALLENGEID1'; PINPOSITIONS := 'PINPOS';
The code is:
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;
The SEC_CHALLENGE table is this
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")
)
here is how I am running it:
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;
If you use output parameters, marked with the "out" keyword, you must pass a variable for that parameter. Output params are not optional. From the error, I gather that you have not done so.
if you are using toad, try it this way:
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;
From the declaration:
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
Your call to CHALLENGEUPDATE
happens to miss an output variable for o_c OUT INTEGER
. You may try the bellow:
exec CHALLENGEUPDATE(
CUSTID => CUSTID
, POLICYNAME => POLICYNAME
, CHALLENGEID => CHALLENGEID
, PINPOSITIONS => PINPOSITIONS
, O_RESULT => O_RESULT
, O_CODE => O_CODE
, O_C => O_C_tobedeclared);
精彩评论