title: Insert default into not null column if value is null
body: <p>I have a table <code>foo</code>, which has a <code>NOT NULL</code> column with a default called <code>message</code>:</p>
  
  <pre><code>CREATE TABLE foo(
      id int PRIMARY KEY,
      message varchar(64) NOT NULL DEFAULT 'Hello'
  )
  </code></pre>
  
  <p>There is a stored procedure <code>bar</code> that inserts into <code>foo</code>:</p>
  
  <pre><code>CREATE PROCEDURE bar(
      i_id int,
      i_message varchar(64)
  )
  BEGIN
  
      -- other logic
  
      IF i_message IS NOT NULL THEN
          INSERT INTO foo (id, message) VALUES (i_id, i_message);
      ELSE
          INSERT INTO foo (id, message) VALUES (i_id, DEFAULT);
          -- could also be: INSERT INTO foo (id) VALUES (i_id);
      END IF;
   END;
  </code></pre>
  
  <p>You can see, I have to conditionally branch in order for my insert to use the default if <code>i_message</code> is null. That's fine for just one column, but consider if <code>foo</code> had many more <code>NOT NULL DEFAULT</code> columns - the syntax would be way to unwieldy.</p>
  
  <p>Is there a syntax I can use to specify that an inserted value should fall back to the default if null? I tried the following but understandably got syntax errors:</p>
  
  <pre><code>INSERT INTO foo (id, message) VALUES (i_id, COALESCE(i_message, DEFAULT));
  INSERT INTO foo (id, message) VALUES (i_id, IFNULL(i_message, DEFAULT));
  </code></pre>