Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

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?

asked 01 Apr '21, 14:32

Frank%20Vestjens's gravatar image

Frank Vestjens
accept rate: 21%

edited 01 Apr '21, 14:32


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

(05 Apr '21, 10:20) Justin Willey

See section 8.11 CREATE TRIGGER in the book.

See also Revisited: Triggering an Audit Trail .

(05 Apr '21, 16:24) Breck Carter
Replies hidden

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

(06 Apr '21, 10:23) Volker Barth
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 01 Apr '21, 14:32

question was seen: 650 times

last updated: 06 Apr '21, 10:24