I try to create a stored procedure through php mysqli. I create another stored procedures and I didn´t have problems. This code:
$link = new mysqli("localhost", "root", "", "Question");
$link -> multi_query("DROP PROCEDURE IF EXISTS FacturaTerminarFactura;
CREATE DEFINER=`root`@`%` PROCEDURE `FacturaTerminarFactura`(IN
id_factura INT(40), Total_factura DOUBLE, Total_IVA DOUBLE)
BEGIN
UPDATE `tb_factura`
SET
`tb_factura`.`intId_factura_resolucion_dian` = (SELECT
MAX(`tb_resolucion_dian`.`intFactura_Actual`) FROM `tb_resolucion_dian`
WHERE `tb_resolucion_dian`.`intEstado` = 1 LIMIT 1),
`tb_factura`.`dblTotal_factura` = Total_factura,
`tb_factura`.`dblIva` = Total_IVA
WHERE `tb_factura`.`intid_factura` = id_factura;
UPDATE `tb_resolucion_dian`
SET `tb_resolucion_dian`.`intFactura_Actual` =
tb_resolucion_dian`.`intFactura_Actual` + 1
WHERE `tb_resolucion_dian`.`intEstado` = 1;
SELECT `tb_factura`.`intId_factura_resolucion_dian` AS ID
FROM `tb_factura`
WHERE `tb_factura`.`intid_factura` = id_factura;
END;");
$log = "";
if ($mysqli -> warning_count) {
if ($result = $link -> query("SHOW WARNINGS;")) {
$row = $result -> fetch_row();
$log .= $row[0]."-".$row[1]."-".$row[2]."
";
$result -> close();
}
}
This is the error
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near '`.`intFactura_Actual` 1 WHERE
`tb_resolucion_dian`.`intEstado` = 1; ' at line 14
I see that the '+' is the problem, but I don't know how I can resolve.
Thanks and excuse me for my English.