DROP PROCEDURE `ModificarUsuario`//
CREATE DEFINER=`root`@`localhost` PROCEDURE `ModificarUsuario`(
IN `Aid` INT,
IN `Aced` VARCHAR(100),
IN `Anombre` VARCHAR(100),
IN `Acargo` VARCHAR(100),
IN `Acedula` VARCHAR(100),
IN `Ausuario` VARCHAR(100),
IN `Apass` VARCHAR(100),
OUT `res` VARCHAR(10) )
BEGIN
SELECT COUNT(usuario) INTO res FROM `usuario` WHERE `cedula`=Aced and `id`<>Aid;
IF res =0 THEN
UPDATE `usuario` SET cedula=Aced, nombre=Anombre, cargo=Acargo, usuario=Ausuario, contrasena=Apass WHERE cedula=Acedula;
END IF;
END
When I use this procedure I get the error «expected 8, got 7.» I don’t understand this, if we look at the code there are 7 input parameters and one out parameter. It seems that the out parameter needs to be specified as well when calling the procedure, any idea why?
user272735
10.5k9 gold badges65 silver badges96 bronze badges
asked Jul 18, 2014 at 5:45
4
You need to reference the out parameter
CALL ModificarUsuario('6','9123','Sandra','Profesor','12345','sandru','sdf',@a)
to see result execute Select @a
or Select res
zzapper
4,7435 gold badges48 silver badges45 bronze badges
answered Jul 18, 2014 at 20:53
andreszam24andreszam24
3512 gold badges3 silver badges12 bronze badges
2
DROP PROCEDURE `ModificarUsuario`//
CREATE DEFINER=`root`@`localhost` PROCEDURE `ModificarUsuario`(
IN `Aid` INT,
IN `Aced` VARCHAR(100),
IN `Anombre` VARCHAR(100),
IN `Acargo` VARCHAR(100),
IN `Acedula` VARCHAR(100),
IN `Ausuario` VARCHAR(100),
IN `Apass` VARCHAR(100),
OUT `res` VARCHAR(10) )
BEGIN
SELECT COUNT(usuario) INTO res FROM `usuario` WHERE `cedula`=Aced and `id`<>Aid;
IF res =0 THEN
UPDATE `usuario` SET cedula=Aced, nombre=Anombre, cargo=Acargo, usuario=Ausuario, contrasena=Apass WHERE cedula=Acedula;
END IF;
END
When I use this procedure I get the error «expected 8, got 7.» I don’t understand this, if we look at the code there are 7 input parameters and one out parameter. It seems that the out parameter needs to be specified as well when calling the procedure, any idea why?
user272735
10.5k9 gold badges65 silver badges96 bronze badges
asked Jul 18, 2014 at 5:45
4
You need to reference the out parameter
CALL ModificarUsuario('6','9123','Sandra','Profesor','12345','sandru','sdf',@a)
to see result execute Select @a
or Select res
zzapper
4,7435 gold badges48 silver badges45 bronze badges
answered Jul 18, 2014 at 20:53
andreszam24andreszam24
3512 gold badges3 silver badges12 bronze badges
2
I receive error 1318 when I call this procedure in MYSQL. What am I doing wrong with this stored procedure? Am I even allowed to do something like this?
CREATE DEFINER=`root`@`localhost` PROCEDURE `CN_renumber`
(
OUT @maxCn,
OUT param1 INT,
OUT update_count INT
)
BEGIN
DECLARE sql_error TINYINT DEFAULT FALSE;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET sql_error = TRUE;
START TRANSACTION;
/*Renumber Cn in DBO*/
/* Set max cn and incremented afterwords */
SET @maxCn = '23206';
UPDATE dbo.billadr SET Cn = (@maxCn:=@maxCn + 1);
IF sql_error = FALSE THEN SET update_count = 1;
COMMIT;
ELSE
SET update_count = 0;
ROLLBACK;
END IF;
END
Matt Busche
14.2k5 gold badges36 silver badges61 bronze badges
asked Mar 11, 2013 at 14:02
7
There was a problem with parameters. Try this procedure, it will fix error 1318 —
CREATE DEFINER='root'@'localhost' PROCEDURE CN_renumber
(OUT maxCn int, OUT param1 int, OUT update_count int)
BEGIN
SET @maxCn = 23206;
UPDATE billadr SET Cn = (@maxCn := @maxCn + 1);
SET maxCn = @maxCn;
END
Usage example —
SET @maxCn = NULL;
SET @param1 = NULL;
SET @update_count = NULL;
CALL CN_renumber(@maxCn, @param1, @update_count);
SELECT @maxCn, @param1, @update_count;
answered Mar 11, 2013 at 14:32
DevartDevart
119k23 gold badges166 silver badges186 bronze badges
2
MySQL stored procedure error: Incorrect number of arguments for PROCEDURE DB.pro_one; expected 1, got 0
1. Problem description
1. When executing the mysql stored procedure: call pro_one();, an error is reported: [Err] 1318-Incorrect number of arguments for PROCEDURE DB.pro_one; expected 1, got 0
2. To the effect: The parameter is incorrect.
3. Execute stored procedure code: call pro_one();
Second, the approximate code of the stored procedure
CREATE PROCEDURE pro_one(out time VARCHAR(20))
BEGIN
SELECT now() into time;
end;
3. Problem analysis and solution
1. According to the general idea of the error message, the parameters of the stored procedure are incorrect.
2. Look at the stored procedure code, there is an out output parameter, and when the stored procedure is called, there is no parameter, so an error is reported.
3. Solution: Determined the problem isMissing parametersCaused, then when calling, just bring the corresponding parameters.
4. Example:
call pro_one(@dates);
SELECT @dates;
Four, summary
1. For the project that has just been taken over, if the parameters of the stored procedure are not clear, there are the following solutions:
a. Use a database visualization tool, such as Navicat: Open the database — Function — Double-click to open — You can see the parameters.
b. Use the command:show CREATE PROCEDURE Stored procedure name; — Determine the parameters of the stored procedure by viewing the form of the source code created by the stored procedure.
c. View the information_schema.Routines biao table to view the stored procedure information.
SELECT * from information_schema.ROUTINES [ where SPECIFIC_NAME=’pro_one’];
If you have a better solution, or unresolved problems, please leave a message to inform us, thank you.