Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

trigger

2 posts in General Discussion Last posting was on 2005-07-28 19:15:39.0Z
shif Posted on 2005-07-28 14:47:03.0Z
Sender: 3130.42e8ec9f.1804289383@sybase.com
From: shif
Newsgroups: ianywhere.public.general
Subject: trigger
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <42e8efe6.313b.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 28 Jul 2005 07:47:03 -0700
X-Trace: forums-1-dub 1122562023 10.22.241.41 (28 Jul 2005 07:47:03 -0700)
X-Original-Trace: 28 Jul 2005 07:47:03 -0700, 10.22.241.41
Lines: 18
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4653
Article PK: 8457

HI
I have 2 tables .I want to use a trigger which sum the
current inserted values of table2 to table1.like below
table2 is having lot of records inserted at many times
i want to sum only the value of records which is currently
inserting
and update to table1.Can anybody please help with a trigger
stmt

table1 table2
------ ---------
id sumvalue id values
1 20 1 10
2 10 2 5
3 30 2 5
3 30
1 10
Thanks


"Rob Waywell" <rwaywell Posted on 2005-07-28 19:15:39.0Z
From: "Rob Waywell" <rwaywell@no_spam.ianywhere.com>
Newsgroups: ianywhere.public.general
References: <42e8efe6.313b.1681692777@sybase.com>
Subject: Re: trigger
Lines: 50
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: rwaywell-xp.sybase.com
X-Original-NNTP-Posting-Host: rwaywell-xp.sybase.com
Message-ID: <42e92edb$1@forums-1-dub>
Date: 28 Jul 2005 12:15:39 -0700
X-Trace: forums-1-dub 1122578139 10.25.98.159 (28 Jul 2005 12:15:39 -0700)
X-Original-Trace: 28 Jul 2005 12:15:39 -0700, rwaywell-xp.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4654
Article PK: 8459

Can you show us the statement level trigger that you have tried?

You should be able to generate the sum using a select against the INSERTED
table:

INSERT INTO t1(sumvalue) SELECT SUM(values) FROM INSERTED


--
-----------------------------------------------
Robert Waywell
Sybase Adaptive Server Anywhere Developer - Version 8
Sybase Certified Professional

Sybase's iAnywhere Solutions

Please respond ONLY to newsgroup

EBF's and Patches: http://downloads.sybase.com
choose SQL Anywhere Studio >> change 'time frame' to all

To Submit Bug Reports:
http://case-express.sybase.com/cx/cx.stm?starturl=casemessage.ssc?CASETYPE=Bug

SQL Anywhere Studio Supported Platforms and Support Status
http://my.sybase.com/detail?id=1002288

Whitepapers, TechDocs, and bug fixes are all available through the iAnywhere
Developer Community at www.ianywhere.com/developer

<shif> wrote in message news:42e8efe6.313b.1681692777@sybase.com...
> HI
> I have 2 tables .I want to use a trigger which sum the
> current inserted values of table2 to table1.like below
> table2 is having lot of records inserted at many times
> i want to sum only the value of records which is currently
> inserting
> and update to table1.Can anybody please help with a trigger
> stmt
>
> table1 table2
> ------ ---------
> id sumvalue id values
> 1 20 1 10
> 2 10 2 5
> 3 30 2 5
> 3 30
> 1 10
> Thanks