title: Insert default value when null is inserted
body: <p>I have an Oracle database, and a table with several not null columns, all with default values. </p>
  
  <p>I would like to use one insert statement for any data I want to insert, and don't bother to check if the values inserted are nulls or not. </p>
  
  <p>Is there any way to fall back to default column value when null is inserted?</p>
  
  <p>I have this code:</p>
  
  <pre><code>&lt;?php
  if (!empty($values['not_null_column_with_default_value'])) {
      $insert = "
          INSERT INTO schema.my_table
              ( pk_column, other_column, not_null_column_with_default_value)
          VALUES
              (:pk_column,:other_column,:not_null_column_with_default_value)
       ";
  } else {
      $insert = "
          INSERT INTO schema.my_table
              ( pk_column, other_column)
          VALUES
              (:pk_column,:other_column)
       ";        
  }
  </code></pre>
  
  <p>So, I have to omit the column entirely, or I will have the error "trying insert null to not null column". 
  Of course I have multiple nullable columns, so the code create insert statement is very unreadable, ugly, and I just don't like it that way.</p>
  
  <p>I would like to have one statement, something similar to:</p>
  
  <pre><code>INSERT INTO schema.my_table
      ( pk_column, other_column, not_null_column_with_default_value)
  VALUES
      (:pk_column,:other_column, NVL(:not_null_column_with_default_value, DEFAULT) );
  </code></pre>
  
  <p>That of course is a hypothetical query. Do you know any way I would achieve that goal with Oracle DBMS?</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>Thank you all for your answers. It seams that there is no "standard" way to achieve what I wanted to, so I accepted the IMO best answer: That I should stop being to smart and stick to just omitting the null values via automatically built statements.</p>
  
  <p>Not exactly what I would like to see, but no better choice. </p>