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!

Sysdate returns different time from system date

Mencis JoeMay 18 2016 — edited May 18 2016

Hi all. I have a trigger that updates some columns of a table. One of those column is 'Last_Updated_Date' which is a timestamp column. When ever user updates the data, this column is updated by a trigger. The trigger is as follows.

CREATE OR REPLACE TRIGGER  "INFO_TRG"

BEFORE insert or update on "INFO_TBL"

for each row

begin

if INSERTING then

select MARKET_ID_SEQ.NEXTVAL

into :new.ID

from dual;

:new.created_date:=sysdate;

:NEW.created_by:=APEX_CUSTOM_AUTH.GET_USERNAME;

:new.LAST_UPDATED_DATE := sysdate;

:NEW.LAST_UPDATED_by:=APEX_CUSTOM_AUTH.GET_USERNAME;

elsif UPDATING then

:new.LAST_UPDATED_DATE := sysdate;

:NEW.LAST_UPDATED_by:=APEX_CUSTOM_AUTH.GET_USERNAME;

end if;

end;

/

The trigger should update the Last_Updated_Date with the sysdate. How ever I see differences in the result. It sometimes even shows time less than the created_date.

When I run

select sysdate from dual;

I am getting the result as '5/18/2016 8:38:43 PM'

I have made an update on the table at the same time. But the Last_Updated_Date shows '18-MAY-16 08:05:57 PM'

What am I missing. What Should I do to get the current time in the Last_Updated_Date column. Thanks.

This post has been answered by Paulzip on May 18 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 15 2016
Added on May 18 2016
13 comments
1,889 views