Home » SQL & PL/SQL » SQL & PL/SQL » Inserting data using a trigger
Inserting data using a trigger [message #1669] Tue, 21 May 2002 03:03 Go to next message
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 #1707 is a reply to message #1669] Thu, 23 May 2002 14:00 Go to previous message
pavani
Messages: 32
Registered: April 2002
Member
u have used a group function count here so try using a group by clause
Previous Topic: SQL Query: User last update record
Next Topic: what : is used for
Goto Forum:
  


Current Time: Tue May 21 20:25:38 CDT 2024