title: Can I lock tables in an IF statement (or a stored proc) in MySQL?
body: <p>This (from body of a stored proc) is throwing a syntax error:</p>
  
  <pre><code>  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
  </code></pre>
  
  <p>do I have to lock any tables I need at the start of the SP?</p>