Inserting data using a trigger [message #20401] |
Tue, 21 May 2002 03:01 |
Michael
Messages: 61 Registered: October 1999
|
Member |
|
|
Hi
i have to write a trigger that stores the values from a shareholder table, company table, sysdate and shares table(the many-many) between shareholder & company which holds the amount of shares owned by a shareholder for a company. this trigger has to fire when the details of the shareholder are updated or deleted.
thanks!
this is what i had
i get bad variable bind errors
create or replace trigger share_trig
before update or delete on shareholder
for each row
declare id integer;
begin
select
count(*) into id
from
company c,
shares sh,
dual
where
c.comp_id = sh.comp_id
AND sh.shareholderid=:old.shareholderid;
if (id>0) then
insert into
temp_table(num_char, char_col, num_col, num_col, sysdate)
values(
:old.comp_id,
:old.comp_name,
:old.shareAmount,
:old.shareholderid,
:old.sysdate);
end if;
end;
|
|
|
Re: Inserting data using a trigger [message #20413 is a reply to message #20401] |
Tue, 21 May 2002 16:36 |
siva
Messages: 58 Registered: August 1999
|
Member |
|
|
Hi Michael,
I can give two suggestions to you,
1) change trigger event from before to after.
This should help you.:old_value is mainly used
in after events.Same problem i faced before
and i solved in this way.
2) change variable name from id to
var_id number;
sometimes column name can be id;
Thanks,
Siva.
|
|
|