Can I lock tables in an IF statement in MySQL?
- by MalcomTucker
This is throwing a syntax error -
--from body of a stored proc
IF (name = in_name)
SET out_id = temp;
ELSE
LOCK TABLE People WRITE;
INSERT INTO People (Name)
VALUES (in_name);
UNLOCK TABLE;
SELECT LAST_INSERT_ID() INTO out_id
END IF
do I have to lock any tables I need at the start of the SP?