title: CREATE TRIGGER x BEFORE INSERT ON y IF q = ''
body: <p>Following is a sample. I am trying to use BEFORE INSERT ON SET and have been to pages of google to look for help. This is the closest I can get:</p>
  
  <pre><code>CREATE TABLE user (alias TEXT, added TEXT);
  
  CREATE TRIGGER user_insert_time 
    BEFORE INSERT ON user 
      FOR EACH ROW 
      BEGIN SET new.added = (datetime('NOW','UTC')));
    END;
  </code></pre>
  
  <p>OR</p>
  
  <pre><code>CREATE TRIGGER user_insert_time 
    BEFORE INSERT ON user 
      FOR EACH ROW BEGIN 
      IF (new.added = '') 
      THEN SET new.added = (datetime('NOW','UTC')));
    END;
  </code></pre>
  
  <p>And I know, I could do following, but then I have to explicitly call out the fields, besides I am kinda hung up on this. </p>
  
  <pre><code>CREATE TABLE user (alias TEXT, added TEXT DEFAULT (datetime('NOW','UTC')));
  </code></pre>