BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL Server trigger

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Alessandro
Guest





PostPosted: Mon Apr 25, 2005 10:57 pm    Post subject: SQL Server trigger Reply with quote



Hi.
I have a table(Moviment) with the follow struct:
MovStock, int
MovProduct, int
MovDateMov, smalldatetime
MovIsn, int (this is order that moviment in this MovDateMov)
MovValue, numeric
MovAverage, numeric

I need write a trigger to when a insert a record this trigger calc the
average. Onother trigger that when i delete a record calc the average from
record deleted until end moviment of the stock / product.

How can i do this?

Thanks
Alessandro




Back to top
Patrick
Guest





PostPosted: Tue Apr 26, 2005 1:14 pm    Post subject: Re: SQL Server trigger Reply with quote



Quote:
MovValue, numeric
MovAverage, numeric
I need write a trigger to when a insert a record this trigger calc the
average. Onother trigger that when i delete a record calc the average from
record deleted until end moviment of the stock / product.
Why not calc the average when you retrieve the data?


Quote:
How can i do this?
See CREATE TRIGGER in MS-SQL BOL. You would derive the average and update

the rows.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.