Re: Need Help with Trigger

From: nix <nix_at_gate.net>
Date: 1996/01/07
Message-ID: <30F08556.1EF1_at_gate.net>#1/1


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 /
-- 
______________________
Robert C. nix_at_gate.net
Received on Sun Jan 07 1996 - 00:00:00 CET

Original text of this message