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.