title: DB2 inserting both timestamp values and null values into a nullable timestamp column
body: <p>When selecting timestamps (which are nullable with defualt null) from a source table through a PHP script and trying to insert into an identical destination table,
  I get the error 'SYNTAX of date, time or timestamp value not valid SQL state 22008'. I believe it's because some source records are null. When the script runs, I get about half the records inserted into my destination table successfully but only the ones that have actual timestamp values. The null records haven't been inserted.</p>
  
  <p>My statements:</p>
  
  <pre><code>    SELECT
          TIMESTAMP_EXPIRATION
      FROM TABLE1;
  
      INSERT INTO TABLE2 (EXPIRATION_T)
      VALUES ($TIMESTAMP_EXPIRATION);
  </code></pre>
  
  <p>The problem is that half of my  source records are null and the other half are TIMESTAMP with a degree of 6</p>
  
  <p>The definition of source and destination tables have the column as 'TIMESTAMP_EXPIRATION FOR COLUMN 0011TTT TIMESTAMP DEFAULT NULL' and 'EXPIRATION_T FOR COLUMN 00EETTT TIMESTAMP DEFAULT NULL'</p>
  
  <p>WHat can I do to get the null values to insert as well?</p>
  
  <p>UPDATE: CREATION STATEMENTS</p>
  
  <pre><code> CREATE TABLE TABLE1 ( 
      ID INTEGER GENERATED ALWAYS AS IDENTITY ( 
      START WITH 1 INCREMENT BY 1 ),
  
      TIMESTAMP_EXPIRATION FOR COLUMN 0011TTT TIMESTAMP DEFAULT NULL )   
  
      RCDFMT TABLE1      ; 
  
  CREATE TABLE TABLE2 ( 
      ID INTEGER GENERATED ALWAYS AS IDENTITY ( 
      START WITH 1 INCREMENT BY 1 ),
  
      EXPIRATION_T} FOR COLUMN 00EETTT TIMESTAMP DEFAULT NULL )   
  
      RCDFMT TABLE2      ; 
  </code></pre>
  
  <p>UPDATE: PHP SCRIPT </p>
  
  <pre><code>    $getDev = "
      SELECT 
          ID,
          TIMESTAMP_EXPIRATION 
      FROM TABLE1
  ";
  
  $stmt = odbc_exec($DB2connDEV, $getDev);
  
  while($gettingItems = odbc_fetch_array($stmt)){
  
      $rows[] = $gettingItems;
  }
  
  foreach($rows as $row){
  
      $originalID = $row['ID'];
      $expiration = $row['TIMESTAMP_EXPIRATION'];
  
  
      $insertTable = "INSERT INTO table2 (id,expiration_t) VALUES (
          $originalID,
          '$expiration')";
  
      $stmt = odbc_exec($DB2connPROD, $insertTable);
  }
  </code></pre>