admin管理员组文章数量:1122846
I have read many posts on stackoverflow regarding this error, but could not find my answer. I have created this procedure on MySQL 8.0 Standard via phpMyAdmin on a shared server :
DELIMITER //
CREATE PROCEDURE CreateUpdateCarrierRange (
IN idCarrier INT,
IN idZone INT,
IN iWeightMin DECIMAL,
IN iWeightMax DECIMAL,
IN price DECIMAL,
IN display INT
)
BEGIN
SET @iCount := 0;
SELECT @iCount, idCarrier, iWeightMin, iWeightMax;
-- Est-ce que la plage existe ? → count retourne une valeur > 0
SELECT @iCount := COUNT(RANGE_WEIGHT.id_carrier)
FROM range_weight as RANGE_WEIGHT
WHERE
RANGE_WEIGHT.id_carrier = idCarrier
AND RANGE_WEIGHT.delimiter1 = iWeightMin
AND RANGE_WEIGHT.delimiter2 = iWeightMax;
IF display = 1 THEN
SELECT @iCount as 'Nombre enregistrements range_weight';
END IF;
END //
DELIMITER ;
I call in phpMyAdmin my stored procedure like this :
CALL CreateUpdateCarrierRange(128, 1, 4.000, 5.000, 10.75, 1)
but I get the error
Static Analysis :
1 error found during the analysis
**Missing expression. (near "ON" at position 25)
SET FOREIGN_KEY_CHECKS = ON;
#2014 - Commands out of sync; you can't run this command now**
In the posts I have read, they speak about missing BEGIN END, missing delimiter, multiple threads (for 1 query ??), ... I must have written something wrong, but I don't see it...
Thanks for your help.
The SHOW CREATE PROCEDURE CreateUpdateCarrierRange;
in phpMyAdmin returns the following :
Procedure : CreateUpdateCarrierRange
**sql_mode :
Create Procedure : CREATE DEFINER=o13084985@% PROCEDURE CreateUpdateCarrierRange
haracter_set_client : utf8mb4
collation_connection : utf8mb4_unicode_ci
Database Collation : utf8mb4_general_ci
I have read many posts on stackoverflow regarding this error, but could not find my answer. I have created this procedure on MySQL 8.0 Standard via phpMyAdmin on a shared server :
DELIMITER //
CREATE PROCEDURE CreateUpdateCarrierRange (
IN idCarrier INT,
IN idZone INT,
IN iWeightMin DECIMAL,
IN iWeightMax DECIMAL,
IN price DECIMAL,
IN display INT
)
BEGIN
SET @iCount := 0;
SELECT @iCount, idCarrier, iWeightMin, iWeightMax;
-- Est-ce que la plage existe ? → count retourne une valeur > 0
SELECT @iCount := COUNT(RANGE_WEIGHT.id_carrier)
FROM range_weight as RANGE_WEIGHT
WHERE
RANGE_WEIGHT.id_carrier = idCarrier
AND RANGE_WEIGHT.delimiter1 = iWeightMin
AND RANGE_WEIGHT.delimiter2 = iWeightMax;
IF display = 1 THEN
SELECT @iCount as 'Nombre enregistrements range_weight';
END IF;
END //
DELIMITER ;
I call in phpMyAdmin my stored procedure like this :
CALL CreateUpdateCarrierRange(128, 1, 4.000, 5.000, 10.75, 1)
but I get the error
Static Analysis :
1 error found during the analysis
**Missing expression. (near "ON" at position 25)
SET FOREIGN_KEY_CHECKS = ON;
#2014 - Commands out of sync; you can't run this command now**
In the posts I have read, they speak about missing BEGIN END, missing delimiter, multiple threads (for 1 query ??), ... I must have written something wrong, but I don't see it...
Thanks for your help.
The SHOW CREATE PROCEDURE CreateUpdateCarrierRange;
in phpMyAdmin returns the following :
Procedure : CreateUpdateCarrierRange
**sql_mode :
Create Procedure : CREATE DEFINER=o13084985@% PROCEDURE CreateUpdateCarrierRange
haracter_set_client : utf8mb4
collation_connection : utf8mb4_unicode_ci
Database Collation : utf8mb4_general_ci
Share
Improve this question
edited Nov 24, 2024 at 12:20
Dominique Delcourt
asked Nov 22, 2024 at 19:12
Dominique DelcourtDominique Delcourt
11 bronze badge
2
|
1 Answer
Reset to default 0Can you try below and check if this helps.
I tried replacing SET with declaring variables as to eliminate the possibility of conflicting SET or session-changing commands (like SET FOREIGN_KEY_CHECKS = ON) in the context where the procedure is being called
DELIMITER //
CREATE PROCEDURE CreateUpdateCarrierRange (
IN idCarrier INT,
IN idZone INT,
IN iWeightMin DECIMAL,
IN iWeightMax DECIMAL,
IN price DECIMAL,
IN display INT
)
BEGIN
DECLARE iCount INT DEFAULT 0;
-- Check if the range exists
SELECT COUNT(RANGE_WEIGHT.id_carrier)
INTO iCount
FROM range_weight AS RANGE_WEIGHT
WHERE RANGE_WEIGHT.id_carrier = idCarrier
AND RANGE_WEIGHT.delimiter1 = iWeightMin
AND RANGE_WEIGHT.delimiter2 = iWeightMax;
-- If display is set to 1, show the count of records in range_weight
IF display = 1 THEN
SELECT iCount AS 'Nombre enregistrements range_weight';
END IF;
-- Optionally, you could add logic here to insert or update records in range_weight based on iCount.
END //
DELIMITER ;
本文标签:
版权声明:本文标题:synchronization - mySql error #2014 - SET FOREIGN_KEY_CHECKS = ON; - Commands out of sync; you can't run this command no 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301364a1931153.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
SHOW CREATE PROCEDURE CreateUpdateCarrierRange;
returns the code which matches your source code. If so then search where this statement is added during your CALL query processing. – Akina Commented Nov 22, 2024 at 19:36