Re: creating a trigger
Posted in 2006
THANKS! Now it works...
"Art S. Kagel" <kagel@bloomberg.net> schreef in bericht
news:45954922.3000003@bloomberg.net...
> Art S. Kagel wrote:
>> Danny De Koster wrote:
>>
>>> hi all!!
>>>
>>> last question of this year....
>>>
>>> I want to use a trigger. Purpose is to keep track of changes in a table.
>>>
>>> create trigger TRIG1>>> after update <field> on <table>
>>> write something in a table
>>>
>>> before the word after....he gives me a syntax error has occurred.....and
>>> I don't know why???
>>>
>>> can anybody help me?
>>> thanks Danny
>>
>>
>> Did you RTFM? See the Guide to SQL Syntax manual.
>>
>> CREATE TRIGGER trig1
>> UPDATE OF somefield ON sometable
>> AFTER INSERT INTO someothertable.....;>
> OOPS forgot the parenthesis around the INSERT statement above.
>
> Art S. Kagel
>
>> But that will only fire once per UPDATE statement and not per row and
>> will fire even if no rows are updated by the statement. If you want to
>> audit changes to every row updated then:
>>
>> CREATE TRIGGER trig2
>> UPDATE OF somefield ON sometable
>> REFERENCING OLD AS orig
>> REFERENCING NEW AS chng
>> FOR EACH ROW (
>> INSERT INTO someothertable ...
>> );>>
>> Art S. Kagel
>>