cancel
Showing results for 
Search instead for 
Did you mean: 

SQL Anywhere 17 - trigger: referencing clause

fvestjens
Participant
0 Kudos
820

In a trigger it is possible to reference old as oldRecord new as newRecord

Then it is possible to use oldRecord.column_name and newRecord.column_name

What type of "variables" are these oldRecord / newRecord?

For example I can't use oldRecord.* to copy all fields into a temp table. Because it does not know the table oldRecord.

But I could for example declare a variable orderRecord orders%rowtype and fill it with 1 given record using

select * into orderRecord from orders where id = 1

Now this orderRecord is acting similar to what oldRecord in the trigger would do.

Select orderRecord.* is not allowed but Select orderRecord.Id is allowed.

So is the oldRecord reference in a trigger similar as a variable declared as table_name%ROWTYPE?

Is there maybe an easy way to have this %ROWTYPE data stored into a table? Maybe by using TABLE REF?

justin_willey
Participant

It might be worth posting the whole of the trigger definition. Also - there is a difference between the behaviour of row and statement level triggers in respect of oldRecord / newRecord - there are some details in the docs

Breck_Carter
Participant

See section 8.11 CREATE TRIGGER in the book.

See also Revisited: Triggering an Audit Trail .

VolkerBarth
Contributor

Wow, thanks for sharing the book as PDF - still got the original paperware on my physical desktops 🙂

Accepted Solutions (0)

Answers (0)