Question : Simple archive trigger for SYBASE table

If TableA has 3 columns: Col1, Col2, Col3.   and I want to create a row in an archive table (tbl_arch), for the Old part of a change operation:

My guess that it would look something like:

CREATE TRIGGER LOGCHANGES1 NO CASCADE BEFORE UPDATE ON dbo.TableA REFERENCING OLD AS O
    FOR EACH ROW
INSERT INTO dbo.tbl_arch  VALUES
(O.Col1, O.Col2, O.Col3, "O")
I think this is what it would look like in db2, what would it look like in sybase?

I need to capture the  date and time stamp (just the system date & time) &  load date.
Can you correct the trigger and complete the definition of the table for system generated fields I am looking for (user, date-time-stamp, load date)

TableA
Col1    char(1)
Col2   char(2)
col3  char(3)
DateTime  ?
Load date

 My question:   Review the trigger and correct any syntax, and complete the table. Provide the system variable name in sybase for the time stamp and load date.  Anything close and I'll award the points.

 

Answer : Simple archive trigger for SYBASE table

Being an ASE engineer, I would say that is ASE.  But I am biased.  :-)

What do you mean by "load date"?  How would that be any different from the current system date and time?


create trigger mytrigger on mytable for update as
insert  dbo.tbl_arch select Col1, Col2, Col3, getdate() from deleted
go

To capture information on the user, use suser_id() or suser_name() as an additional value.
 
Random Solutions  
 
programming4us programming4us