Answer the question
In order to leave comments, you need to log in
What is the correct way to write stored procedures in MySQL with an IF/THEN/ELSE block inside? (Users of IntelliJ IDEA also here)?
The full question sounds like this: How to write a stored procedure in MySQL, inside which there is an IF THEN ELSE block, so that this script can then be executed from different environments without syntax errors?
I'll explain...
SQL script can be executed in different ways:
Answer the question
In order to leave comments, you need to log in
I've never had a problem with this syntax:
DELIMITER $$
DROP PROCEDURE IF EXISTS `sp_test`$$
CREATE DEFINER=`user`@`%` PROCEDURE `sp_test`(
IN Number INT
)
READS SQL DATA
BEGIN
--
-- Код здесь
--
END$$
DELIMITER ;
This suggests that the SQL syntax was done by idiots. What the fuck is DELIMITER? There is no such (keyword) in normal programming languages.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question