I have the following procedure, which is to add a record to a table if there isn't already one in the table.
BEGIN
IF NOT EXISTS (SELECT * FROM gearLog
WHERE code = @codeI
AND signeeID = @signeeIDI
AND signoutDate = @signoutDateI
AND signbackDate = NULL)
BEGIN
INSERT INTO gearLog (code, signeeID, signoutDate, signbackDate, committeeOutID, committeeInID,
warningsGiven)
VALUES (@codeI, @signeeIDI, @signoutDateI, NULL, @committeeI, NULL, 0)
END
END
For the following table
However when I go to submit it, I get the following error:
MySQL said: #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 'BEGIN INSERT INTO gearLog (code, signeeID, signoutDate, signbackDate, ' at line 7
I don't know what is syntactically wrong with that part though. If anyone could help I would appreciate it.
Here is how it looks in phpMyAdmin