Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Still my trigger!
I don't think the trigger you posted will work. MY_TABLE will be
inaccessible in a row-level trigger because it is in the process of being
changed.
For example suppose the SELECT COUNT(*) ... in your trigger were modified as follows:
SELECT COUNT(*) INTO i
FROM MY_TABLE
WHERE NAME LIKE 'M%'
Then, when you issue a DELETE FROM MY_TABLE, the values that get inserted
into MY_TABLE_2 really depend on the order in which the rows are deleted
from the table. This is a cardinal sin in a relational database, so Oracle
will return an error stating that table MY_TABLE is mutating.
Other than that problem, your reference to :OLD.MY_ROW1 is valid, as long as MY_ROW1 is a column in MY_TABLE.
Good luck,
Matt
barthon wrote in message <7j6cpp$6pd$1_at_jaydee.iway.fr>...
>Hi,
>
>I've got an other question about the triggers :
>
>CREATE OR REPLACE TRIGGER test
>BEFORE DELETE ON MY_TABLE
>FOR EACH ROW
>DECLARE
> i INTEGER;
>BEGIN
> SELECT COUNT(*) INTO i
> FROM MY_TABLE;
>
> INSERT INTO MY_TABLE_2
> VALUES(:OLD.My_row1,i);
>END;
>
>I would like execute a statment "ON MY_TABLE" in my trigger AND get an old
>element.
>
>Is it possible ?
>
>Thank's for your answers.
>
>JP
>
>
Received on Fri Jun 04 1999 - 18:35:30 CDT
![]() |
![]() |