简体   繁体   中英

Oracle procedure call results in “PLS-00306: wrong number or types of arguments in call”

I'm trying to create a procedure in SQL. It compiles correctly with no errors, but when I try to run it I keep getting the same syntax error.

Here is the error:

exec reset_password(2002)
Error report -
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'RESET_PASSWORD'
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:

My query:

 CREATE OR REPLACE PROCEDURE reset_password
 (
 p_customer_id  NUMBER,
 p_ret_code    OUT NUMBER,
 p_ret_message   OUT VARCHAR2 
 ) 
 AS
 old_password  VARCHAR2(10);
 new_password  VARCHAR2(10);
 vnumb NUMBER;
 ret_code    NUMBER;
 ret_message   VARCHAR2(50);
 Begin
    Select count(*)
    into vnumb
    from customer
    where customer_id = p_customer_id;

    If vnumb = 0 then
    ret_code:= 11;
    ret_message:= 'help';     
    Else
   ret_code:= 69;
   ret_message:= 'train';     
   return;
    end if;
   p_ret_code:= ret_code;
   p_ret_message:= ret_message;
    end reset_password;






CREATE TABLE customer 
( CUSTOMER_ID           NUMBER PRIMARY KEY,
 PASSWORD           VARCHAR2(20) NOT NULL,
 NAME           VARCHAR2(20) NOT NULL,
 EMAIL_ADDRESS      VARCHAR2(50) NOT NULL,
 PHONE_NUMBER       VARCHAR2(15) NOT NULL,
 REGISTRATION_DATE  DATE NOT NULL,
 EXPIRATION_DATE    DATE NOT NULL, 
 LAST_UPDATE_DATE   DATE NOT NULL);

 INSERT INTO customer 
 VALUES(2001, 'CpsBTKpN','SMITH','smith@yahoo.com', '3123622345',
'02-FEB-2010', '01-FEB-2015', '02-FEB-2010');
INSERT INTO customer 
VALUES(2002, 'ZWNWnQJT9', 'JONES', 'jones@hotmail.com', '6302077890',
'03-MAR-2010', '02-MAR-2015', '31-DEC-2010');
INSERT INTO customer 
VALUES(2003, 'gc88Wmvpx', 'MILLER', 'miller@abc.com', '6303551234',
'09-APR-2010', '08-APR-2015',   '09-APR-2010');
INSERT INTO customer 
VALUES(2004, 'KcxweSYg555', 'JOHNSON', 'jo12@gmail.com', '7732015678',
'22-APR-2010', '21-APR-2015', '22-APR-2010');
INSERT INTO customer 
VALUES(2005, 'CDYe44BBXd', 'CLARK', 'clark12@dpu.edu', '8476391001',
'18-MAY-2010', '17-MAY-2015', '18-MAY-2010');
INSERT INTO customer 
VALUES(2006, 'xGqmkw345zr', 'LEWIS', 'lewis@ual.com', '2246166666',
'20-MAY-2010', '19-MAY-2015', '20-MAY-2010');
INSERT INTO customer 
VALUES(2007, 'Y79zAHQwcB', 'KING', 'king@yahoo.com', '3018551234',
'30-JUN-2010', '29-JUN-2015', '30-JUN-2010');
INSERT INTO customer 
VALUES(2008, 'vhSDHMDg66', 'SCOTT', 'scott@hotmail.com', '7701239876',
'30-AUG-2010', '30-DEC-2011',   '30-DEC-2011');
COMMIT;

To run your procedure, one can create an anonymous plsql block with a declaration associated with the out parameters:

p_ret_code    OUT NUMBER,
p_ret_message   OUT VARCHAR2 

Apparently, you are not passing three parameters (two being out) with your procedural invocation. This is why you are receiving the error:

PLS-00306: wrong number or types of arguments in call to 'RESET_PASSWORD' 

I use l_ret_code and l_ret_message with matching data types.

DECLARE
  l_ret_code    NUMBER;
  l_ret_message VARCHAR(50);
BEGIN
  reset_password ( 2002, l_ret_code, l_ret_message);
END;

If one would like to use the execute command to run the procedure with the out parameters, using bind variables will work:

var l_ret_code    NUMBER;
var l_ret_message VARCHAR2(50);
EXECUTE reset_password ( 2002, :l_ret_code, :l_ret_message);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM