All Forums Database
rtefft 11 posts Joined 03/09
21 May 2013
Odd timestamp applied in update when timestamp variable in stored procedure is null 0000-00-00 00:04:00

In a stored procedure a timestamp variable has been set (via a cursor select) to null.
When using that variable to update a timestamp column of another table, the updated value resolves as
0000-00-00 00:04:00  instead of null.
It does not vary when many records are processed through the SP, always just 4 minutes. 
Have not been able to predicted when we will get a null (as desired) or get a 0000-00-00 00:04:00 (not)
No date math occurring nearby. 
  update x_tbls.aircraft_custody
  set end_ts = c_custody_end_ts,
  source_name = 'XXXX', last_alter_ts = w_last_alter_ts where
  acft_serno = w_acft_serno and action_ts =
    (select max(action_ts) from x_tbls.aircraft_custody
     where acft_serno = w_acft_serno and
     action_ts < w_action_ts);

You must sign in to leave a comment.