Wednesday, December 29, 2021

[FIXED] ERROR: SET FOREIGN_KEY_CHECKS = ON and #2014 - Commands out of sync; you can't run this command now

Issue

in PHPMYADMIN i want to call function that was in stored procedure and so i run a query this is one , CALL funcpara ('karthick');

FUNCTION CODE:

CREATE PROCEDURE `funcpara`(IN `uname` VARCHAR(255)) 
SELECT ct.CUST_NM, UPPER(CUST_NM) AS UppercaseCustomerName 
FROM customers ct
WHERE ct.CUST_NM = uname; 

i was enter a input value for parameter as above query, there was an error shows that was-

Error

Static analysis:

1 errors were found during analysis.

Missing expression. (near "ON" at position 25) SQL query: Edit Edit

SET FOREIGN_KEY_CHECKS = ON;

MySQL said:Documentation

#2014 - Commands out of sync; you can't run this command now

give me a solution if any knows, thanks for advance


Solution

You are missing BEGIN and END and the DELIMITER part.

Try:

DELIMITER //
CREATE PROCEDURE funcpara(uname VARCHAR(255)) 
BEGIN
SELECT CUST_NM, UPPER(CUST_NM) AS UppercaseCustomerName 
FROM customers ct
WHERE CUST_NM = uname; 
END//
DELIMITER ;

enter image description here



Answered By - Ergest Basha

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.