Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: trigger to insert a few records

Re: trigger to insert a few records

From: Mark Gumbs <mgumbs_at_nospam.hotmail.com>
Date: Wed, 16 Jun 1999 11:20:49 +0100
Message-ID: <37677835.0@145.227.194.253>


You haven't supplied what the error message was.

Try removing the declare from your code, the trigger may not need it since you only use declare when using anonymous blocks.

Also your first line should read

create or replace trigger trig1_user_supplier_seq1 after insert as ....

Mark

daud11_at_hotmail.com wrote in message <7k7q5u$fno$1_at_nnrp1.deja.com>...
>Hi
>
>I am trying to create a trigger that will insert a few records into
>table B whenever there is an insert in table A. The code that I have is
>giving me compilation errors and I am not sure why.
>
>code for trigger of table suppliers:
>************************************
>
>create or replace trigger trig1_user_supplier_seq1
>after insert
>on suppliers
>declare
> cursor users_cursor is
> select userid from users;
> tmp_userid char(2);
>begin
> open users_cursor;
> loop
> fetch users_cursor into tmp_userid;
> exit when users_cursor%NOTFOUND;
> insert into user_supplier_seq
> values (tmp_userid, supplierid , 0)
>
> end loop;
> close users_cursor;
>end;
>
>***************************************
>
>Basically, whenever a new supplier record is added, I would like to add
>all users found in users table together with the current supplier id
>and 0 into the user_supplier_seq table.
>The problem is at the insert statement (supplier id) but I am not sure
>how to correct it. I need the current value of the supplier id (the one
>which has just been inserted and fired the trigger). I have tried
>:new.supplierid for supplierid but still did not work because :new can
>only be used for row trigger.
>
>Hope to get some help from this forum.
>
>thanks
>Daud
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
Received on Wed Jun 16 1999 - 05:20:49 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US