Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Pls Help- what is wrong with my code?
You can't select on a table you are updating/inserting/deleting in a trigger
for each row.
remove the "for each row" to convert your row level statment trigger to
statment level trigger
Johnson Chao wrote in message <7obkah$ujs$1_at_nnrp1.deja.com>...
> Hello:
> I want to make a very easy trigger like this.
>
> ztable with c1, c2 two columns
> After delete a record from ztable, check to see if there is still
>records in ztable where c2=5, then my code is as followed:
>
>create or replace trigger aaa
>After Delete on ztable
>for each row
>DECLARE
> i integer;
>BEGIN
> select count(*) into i from ztable where c2=5;
> if i=0 then
>-- do something
> end if;
>END;
>
>
>Though there is no compile error on it, when I delete a record from
>ztable1, I was told ora4091 error ."ztable1 is mutating, ...can not see
>it".
> What is wrong with my code?
>
> Thanks
>
>--
>Johnson Chao
>ctc Japan
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Thu Aug 05 1999 - 05:33:10 CDT