Re: Need Help with Trigger

From: Chuck Hamilton <chuckh_at_ix.netcom.com>
Date: 1996/01/09
Message-ID: <4cui0g$7l3_at_ixnews8.ix.netcom.com>#1/1


nix <nix_at_gate.net> wrote:

>Jim Smith wrote:
>>
>> In article <gdouglas.5.0000253A_at_mailhost.wlc.com>, Gerry Douglas
>> <gdouglas_at_mailhost.wlc.com> writes
>> >Hi, I've just started learning Oracle and I have some problem creating trigger.
>> >Basically, I typed in something like this in PL/SQL:
>> >
>> > >create trigger trig_test
>> > 2 after insert or update
>> > 3 on tab1
>> > 4 begin
>> > 5 select * from tab1;
>> > 6 end;
>> > 7 .
>> >
>>
>> You have two problems here. The first is that you you haven't created a
>> trigger. You will need to enter '/' on the line after you PL/SQL block
>> to execute it. You should then get a message saying whether the trigger
>> created successfully or not.
>>
>> You second problem is that "select * from tab1" is not valid in a
>> trigger, and even if it was, nothing would be displayed (a trigger does
>> not have access to the output of your session).
>> --
>> Jim Smith
 

>Select second point here is incorrect. You can do 'select *' in a trigger. Just
>not that way. And you can output data from a trigger by using DBMS_OUTPUT.
>example:
 

>SQL> create trigger trig_test
> 2 after insert or update on tab1
> 3 declare
> 4 cursor c_tab1 is select * from tab1;
> 5 begin
> 6 for t in c_tab1 loop
> 7 dbms_output.put_line(to_char(t.n)); - n must be a column in tab1
> 8 end loop;
> 9 end;
> 10 /

Won't this generate the old "mutating table" problem.

--
Chuck Hamilton
chuckh_at_ix.netcom.com

Never share a foxhole with anyone braver than yourself!
Received on Tue Jan 09 1996 - 00:00:00 CET

Original text of this message