> -----Original Message-----
> From: Kolja Kleist [mailto:[EMAIL PROTECTED]]
> Sent: Freitag, 5. April 2002 17:45
> To: [EMAIL PROTECTED]
> Subject: triggers
>
>
> Hello,
>
> I have the following table:
>
> CREATE TABLE test(
> id fixed(10) not null primary key
> , uname varchar(32) DEFAULT USER
> , uname_upd varchar(32) DEFAULT USER
> , text varchar(128) NOT NULL
> )
>
> Now I want to have a trigger, that updates the 'uname_upd'
> column with the
> user name that updates the record:
>
> CREATE TRIGGER test_update FOR test AFTER UPDATE EXECUTE (
> TRY
> UPDATE owner.test SET uname_upd = USER WHERE id = :OLD.id;
> CATCH
> STOP ($rc, 'Unexpected error');
> )
>
> This works fine, but I want to know, if there is a better way.
> Does the DB-Kernel detects the endless loop this trigger
> normaly should produce?
> Could you also tell me, how long the trigger name can be?
To make sure that the update trigger will not fire after updating because of
the trigger,
you can use the column_list behind the UPDATE as described in the manual:
<create_trigger_statement> ::= CREATE TRIGGER <trigger_name> FOR
<table_name>
AFTER <trigger_event,..> EXECUTE (<routine>) [WHENEVER <search_condition> ]
<trigger_event> :: INSERT | UPDATE [(<column_list>)] | DELETE
<column_list> ::= <column_name> | <column_list>,<column_name>
trigger_name has a maximum length of 32 character.
Elke
SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general