I have a stored procedure which is syntactically acceptable on my local PC, where I have MySQL workbench 5.2.44 and I think my local version of MySQL is 5.5.29 judging by the folder names. Here is the code, which I have reduced to a minimum for illustration
DELIMITER $$
CREATE PROCEDURE `usp_insert_booking_test_2`(
IN p_dtmTimeSlot DATETIME
)
BEGIN
INSERT INTO tblBookings (dtmTimeSlot)
SELECT p_dtmTimeSlot
FROM tblBookings
WHERE NOT EXISTS (SELECT * FROM tblBookings WHERE dtmTimeSlot = p_dtmTimeSlot) LIMIT 1;
END$$
As you can see, I am trying to ensure I do not create two bookings in the same time slot. Yes, I have a constraint on the table to do this also. Belt & braces. When I try to add this procedure on my remote host (running MySQL version 5.1.68-cll), it says
#1064 - 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 '' at line 12
Line 12 is the WHERE NOT EXISTS line. I have tried removing LIMIT 1, that makes no difference. Is there a way to write the query so that MySQL 5.1 will accept it?