Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Stored Procedure stores data in Date field with Year and Day switched.

118236Jul 9 2008 — edited Jul 10 2008
We experienced a full system crash a few weeks ago and had to restore the database from a dump file. This actually happened twice. In between the two restores a job that runs a Stored Procedure overnight began inserting a date in a particular date field with the year and day transposed. ie. if the date was supposed to be 23-JUN-2008 it was stored as 08-JUN-2023.

After the second restore things were back to normal and only the records updated during the initial inbetween period were affected. I have narrowed it down to the following statement in the Stored Procedure.

select to_date(to_char(trunc(sysdate -1))||' 23:59:00','DD-MM-YY HH24:MI:SS'),sysdate
into sysdate1,sysdate2
from dual;

During the problem period whenever the variable 'sysdate1' above is stored to a table in a date field the problem was manifest.

ie.
UPDATE <table>
SET last_modified_date = sysdate1;
WHERE expiry_date = <whatever>

Both the variable sysdate1 and the field last_modified_date are of data type DATE.

Does anyone have any idea of where I can look to explain how this happened? I have been playing with NLS_DATE_FORMAT and language settings in Oracle but to no avail.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 7 2008
Added on Jul 9 2008
3 comments
318 views