title: MySQL trigger before Insert value Checking
body: <p>I have a table <code>staff</code> with <code>office</code> column. Currently the <code>office</code> column do not accept NULL values. The application persisting onto this table has a bug which meant that, when the staff has not been assigned an office, it tries inserting a NULL value onto the table.</p>
  
  <p>I have been asked to used a trigger to intercept the insert onto the <code>Staff</code> table and check if the <code>office</code> value is NULL and replace it with value <code>N/A</code>. </p>
  
  <p>Below is my attempt so far, but do have <code>error</code> in attempt to implement. Any Ideas on how to resolve this.</p>
  
  <pre><code>CREATE TRIGGER staffOfficeNullReplacerTrigger BEFORE INSERT ON Staff
    FOR EACH ROW BEGIN
      IF (NEW.office IS NULL)
       INSERT INTO Staff SET office="N/A";
      END IF
    END;
  </code></pre>
  
  <p><strong>The error:</strong></p>
  
  <blockquote>
    <p>MySQL Database Error: 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 'INSERT INTO Staff SET office="N/A"; END'</p>
  </blockquote>