Error in stored process of adding

0

Hello, how am I trying to perform a process stored in my sql database to add to my table Clientes

This is the stored process that I am using:

CREATE PROCEDURE agregarClientes(Codigo int, Nombre varchar(15), Apellido varchar(30), Direccion varchar(50), Fecha_Nacimiento Date, Tipo int, Foto varchar(55), Fecha_Ingreso Date, Ganancia double) 
INSERT INTO empleados VALUES (Nombre,Apellido,Direccion,Fecha_Nacimiento,Tipo,Foto,Fecha_Ingreso,Ganancia)

And this is the part of how I send it to call:

call agregarClientes("ejemplo","ejemplo","Conocido","1991-03-30","1","ejemplo","1-04-2018","2500")

But I get the following error when executing the query:

1318 - Incorrect number of arguments for PROCEDURE add Customers; expected 9, got 8

My id field is autoincrementable and as I have usually used it, I do not need to enter the part of the parameters when I call it

    
asked by SEBAS 13.04.2018 в 04:51
source

3 answers

0

This is the structure of my employees table

    
answered by 13.04.2018 в 05:49
0

You just have to take it out of the parameters that the procedure expects:

CREATE PROCEDURE agregarClientes(Nombre varchar(15), Apellido varchar(30), Direccion varchar(50), Fecha_Nacimiento Date, Tipo int, Foto varchar(55), Fecha_Ingreso Date, Ganancia double).

After:

call agregarClientes("ejemplo","ejemplo","Conocido","1991-03-30",1,"ejemplo","1-04-2018",2500)
    
answered by 13.04.2018 в 05:39
0

You must modify the insert statement in your procedure and add the fields you are going to enter. I think it's better to change the names of the input variables of the procedure so that it does not conflict with the names of the fields.

CREATE PROCEDURE agregarClientes(vNombre varchar(15), vApellido varchar(30), vDireccion varchar(50), vFecha_Nacimiento Date, vTipo int, vFoto varchar(55), vFecha_Ingreso Date, vGanancia double) 
INSERT INTO empleados 
(Nombre,Apellido,Direccion,Fecha_Nacimiento,Tipo,Foto,Fecha_Ingreso,Ganancia) 
VALUES (vNombre,vApellido,vDireccion,vFecha_Nacimiento,vTipo,vFoto,vFecha_Ingreso,vGanancia)
    
answered by 13.04.2018 в 15:19