Article View: borland.public.interbase.sql
Article #397trigger to get sum
From: Isaac
Date: Sat, 17 May 2008 23:01
Date: Sat, 17 May 2008 23:01
27 lines
1274 bytes
1274 bytes
Hello,
I am new to triggers and I wonder if I can get sum of a field in the
table (a) for the current item (f1) and then update another field in
table (b) like that:
Table a
f1 pk (id)
f2 float
table b
fb1 pk
fb2 float <<--- need update
trigger body:
AS
DECLARE VARIABLE sum_var float;
begin
sum_var = select sum(f2) from table_a
where f1 = ?;
update table_b set fb2 = sum_var where fb1 = ??;
end
Please advice
Thanks
Technical Details
Message-ID:
<482f63f1$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,c564685cdb1305db,start X-Google-Attributes: gid114a0e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Sun, 18 May 2008 02:01:51 +0300 From: Isaac <no@no.com> User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: borland.public.interbase.sql Subject: trigger to get sum Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 41.234.198.147 Message-ID: <482f63f1$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1211065329 41.234.198.147 (17 May 2008 16:02:09 -0700) Lines: 27 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail