-1

I am using Sybase ASE 15.0.3 and DBArtisan 8.5.3.

I am trying to create a trigger that puts data into audit tables when a table gets updated.

My code is something like

CREATE TRIGGER AUDIT_TRG ON TABLE A
FOR INSERT,UPDATE 
REFERENCING OLD AS OLD NEW AS NEW

I am getting a syntax error stating incorrect syntax near referencing. If I specify only old or new i get a different error as OLD or NEW is not valid identifier or something like that (I am unable to remember the exact error)

I even tried using :old and :new but they dont seem to be working.

Please let me know how can i access the old and new record values of the table being updated.

aF.
  • 64,980
  • 43
  • 135
  • 198
  • Maybe try reading the [documentation](http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.ase_15.0.commands/html/commands/commands29.htm)? Sybase, like SQL Server, has `inserted` and `deleted` pseudo tables, rather than `old` and `new`. – Damien_The_Unbeliever Feb 23 '12 at 07:58

1 Answers1

0

To use new and old you don't need to create a reference for new as new and old as old.

For example, you have to do it like this:

new.record_name
old.record_name

If you want to use some variable then you have to create a referencing like this:

referencing OLD as some_variable

And then you use this variable in the following way:

some_variable.record_name
honk
  • 9,137
  • 11
  • 75
  • 83