Oracle过程调用导致" PLS-00306:调用中的参数数量或类型错误"

时间:2014-08-13 18:16:10

标签: sql oracle

我试图在SQL中创建一个过程。它正确编译没有错误,但当我尝试运行它时,我不断得到相同的语法错误。

这是错误:

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:

我的查询:

 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;

1 个答案:

答案 0 :(得分:4)

要运行您的过程,可以使用与out参数关联的声明创建一个匿名plsql块:

p_ret_code    OUT NUMBER,
p_ret_message   OUT VARCHAR2 

显然,您没有通过程序调用传递三个参数(两个是out)。这就是您收到错误的原因:

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

我使用l_ret_code和l_ret_message匹配数据类型。

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

如果想使用execute命令运行带有out参数的过程,使用绑定变量将起作用:

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