I have a problem calling several times in a row (within a while) to a procedure (with the CALL nameProcedure (parameter)) from php on my website.
This is the code of the procedure:
BEGIN
SELECT
@estado := estade,
@subestado := subestado
FROM
tabla1
WHERE boletin = boletn; #(el "boletn" es el parametro que paso al procedimiento)
CASE @estado
WHEN 'estado1' THEN
CASE @subestado
WHEN '' THEN
SET @tipo = 'Pendiente';
ELSE
SET @tipo = 'Sin identificar';
END CASE;
END CASE;
UPDATE tabla1 SET tipo = @tipo WHERE boletin=boletn;
And then in php I have the following:
$instruccion0 = "SELECT boletin FROM tabla1 ORDER BY fechaCarga DESC LIMIT 4";
$resultado0 = mysql_query($instruccion0, $conexion);
while($fila0 = mysql_fetch_assoc($resultado0)){
$boletin = $fila0['boletin'];
$resultado1 = mysql_query("CALL establecerTipoBoletin('$boletin')", $conexion) or die ("Fallo en el CALL procedimiento. Error: " . mysql_error());
}
And this is where the problem comes from. Of course, what I need is that the 4 bulletins in the table (putting there are 4), the procedure is executed, that is, call each time a different bulletin, so that the while
in php But when I do the action (that the php code is "executed" when I press a button) it shows me the following error message:
Failed in the CALL procedure. Error: Commands out of sync; you can not run this command now
In theory that error is due to the fact that the CALLS are being performed at the same time, but depending on what is being programmed, it enters the while, executes a call to a newsletter, re-enters the while, executes the call to the another newsletter ...
Note: If I do it with only 1 bulletin (changing the 1 by the 4 in "SELECT boletin FROM tabla1 ORDER BY fechaCarga DESC LIMIT 4";
) if it does it correctly and it does not show me the error (only logically it only enters the once while).
Does anyone know why that error message?
EDITED:
I have verified that the same error message occurs if I execute the same procedure 2 times in a row, that is, if I do twice the CALL
. If I do this:
$resultado1 = mysql_query("CALL establecerTipoBoletin('boletin1')", $conexion);
$resultado1 = mysql_query("CALL establecerTipoBoletin('boletin2')", $conexion);
Skip the same error message.
Greetings.