Article View: borland.public.interbase.sql
Article #382Re: cumulative balance field
From: WillR
Date: Thu, 08 May 2008 18:08
Date: Thu, 08 May 2008 18:08
40 lines
2659 bytes
2659 bytes
Bill Todd [TeamB] wrote: > Isaac wrote: > >> In fact debit and credit fields can be changed by user at any time, I >> think I will need another trigger ? plz post any short examples of >> triggers I did not use them before > > In that case storing the running balance may be expensive since a > change to the debit or credit amount in any row will change the balance > for every subsequent row. Triggers and stored procedures are explained > in the IB Data Definition Guide. It is impossible to explain the entire > subject of triggers in a newsgroup message. After you read the Data > Definition Guide chapters on stored procedures and triggers you can > post any specific questions you have and someone will try to answer > them. > His post says cumulative balance -- that is easy. I think he means a "running balance" -- as you have assessed. That is not always easy as you have pointed out -- as it is sequence dependent. Whenever you implement such a feature, they tend to "become wrong" exactly as you pointed out. So you always need to have routines which sequentially "fix" the running account balance -- for each entry. ACCPACC in it's DOS days definitely had those routines built in -- as did many other accounting systems. It is usually easier -- on a fast server -- to calculate the balance to a required point via SQL queries. If a cumulative balance is required -- I would suggest a stored procedure which runs a calculation routine on demand. It is procedural/sequential after all. -- Will R PMC Consulting
Technical Details
Message-ID:
<482340ba$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4822380f@newsgroups.borland.com> <482246d0$1@newsgroups.borland.com> <48231e5b$1@newsgroups.borland.com> <48233ade@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,7fe0f2b0b1ac1758 X-Google-Attributes: gid114a0e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 08 May 2008 12:08:01 -0600 From: WillR <willrNo.Spam.pmccl.noSpam.com> User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) MIME-Version: 1.0 Newsgroups: borland.public.interbase.sql Subject: Re: cumulative balance field References: <4822380f@newsgroups.borland.com> <482246d0$1@newsgroups.borland.com> <48231e5b$1@newsgroups.borland.com> <48233ade@newsgroups.borland.com> In-Reply-To: <48233ade@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 189.174.196.62 Message-ID: <482340ba$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1210269882 189.174.196.62 (8 May 2008 11:04:42 -0700) Lines: 40 Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail