Re: use of triggers

From: Jeff Hayward <hayward_at_quip.eecs.umich.edu>
Date: 18 Apr 1994 21:07:30 GMT
Message-ID: <2ousqj$30f_at_zip.eecs.umich.edu>


>my first thougth was, to let a trigger compute the key field when
>inserting new data. but triggers are not allowed to insert in the
>same row as the insert-statement that started the trigger.
>problems also occur when a trigger updates a foreign key that
>references a table/row on which the trigger-starting-statement is
>working.
>does anybody use the triggers? what for?
>
>bye,
>dirk

I use a PRE-COMMIT trigger to put in my own Primary Key usually from a sequence. I just do:

Trigger: PRE-COMMIT
  SELECT sequence_name.nextval INTO :PRIMARY_KEY_FIELD FROM DUAL;

This works fine.

You could do the same thing without a sequence and calculate prior to commit the key value based on fields entered on the form.

Hope this helps.

Jeff.Hayward_at_umich.edu Received on Mon Apr 18 1994 - 23:07:30 CEST

Original text of this message