Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Does Oracle have a TimeStamp like SQL Server?
Message
General information
Forum:
Oracle
Category:
Other
Miscellaneous
Thread ID:
00405498
Message ID:
00405588
Views:
18
>Hi All,
>I am just now converting our application to use Oracle as a backend. I have successfully used SQL Server in the past. I sent my SQL Server scripts to the Oracle DBA and they questioned the "timestamp" datatype. I was told Oracle has no such thing and this would have to be implemented via a trigger. Is that really the case?
>TIA,

Yes. The trigger is exteremely easy to implement. Sample Oracle trigger code:
create or replace trigger FACILITY_BEFORE_INSUPDT
before insert or update on npdes.FACILITY for each row
declare
v_Id   Number;
v_User Char(8);
v_Date Date;
BEGIN
 select USER into v_User from dual;
 :new.Updated_By := v_User;
 select SYSDATE into v_Date from dual;
 :new.Last_Update := v_Date;
 If :new.KeyID Is Null or :new.KeyID < 1 Then
 select s_npdes_FACILITY.nextval into v_Id from dual;
 :new.KeyID := v_Id;
End If;
End;
/
There are 2 fields being updated by this trigger -- UPDATED_BY and LAST_UPDATE. UPDATED_BY is being set equal to the system variable USER. LAST_UPDATE is set equal to the system variable SYSDATE.

If this is a new record, the KEYID column is being set equal to the next sequence number returned by retreiving the NEXTVAL from the S_NPDES_FACILITY sequence. This is how I populate my primary key fields which are NUMBER(10) data type.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform