title: My MySQL after INSERT trigger isn't working? Why?
body: <p>I've created a trigger that resembles the following:</p>
  
  <pre><code>delimiter //
  CREATE TRIGGER update_total_seconds_on_phone AFTER INSERT
  ON cdr 
  FOR EACH ROW 
  BEGIN
  IF NEW.billsec &gt; 0 AND NEW.userfield &lt;&gt; NULL THEN
  UPDATE foo
  SET total_seconds = total_seconds + NEW.billsec
  WHERE phone_id = NEW.userfield;
  END IF;
  
  END;//
  </code></pre>
  
  <p>It seems to go through okay. However it doesn't appear to be invoking when I need it to.  Here's an example:</p>
  
  <pre><code>mysql&gt; select total_seconds from foo where phone_id = 1;
  +---------------+
  | total_seconds |
  +---------------+
  |             0 | 
  +---------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>mysql> insert into cdr (billsec, userfield) VALUES(60, 1);
  Query OK, 1 row affected, 12 warnings (0.00 sec)</p>
  
  <pre><code>mysql&gt; select total_seconds from foo where phone_id = 1;
  +---------------+
  | total_seconds |
  +---------------+
  |             0 | 
  +---------------+
  </code></pre>
  
  <p>EDIT: The warnings in this particular case do not affect the trigger. It's mostly additional columns which do not have default values in the cdr table that cause the warnings. For the sake of simplicity, I kept my INSERT statement brief.</p>