----- Original Message -----
Sent: Wednesday, February 09, 2005 3:46
PM
Subject: [RBG7-L] - Re: How can I do
this in RBase
As is normal, there are always several ways to accomplish
the same goal. For instance, some prefer not to "store"
the balance, but calculate it every time they access a
customer.
Others want to keep a running daily transaction history, and
want it recorded each day, so a "day end batch" job runs and
updates a "daily totals" table.
Please note that your question about editing a record in the
"middle" is valid, if you are keeping a running total. Once
you edit the "middle" record, all subsequent rows would have
to be updated. This can get very messy. Thus the reason why
many running balances are calculated in reports and not actually
kept as a record.
Using triggers, one does have to consider several issues. (Such
as if you wanted to import a large amount of records, the
triggers
would fire after each, etc.)
But to accomplish what you are asking, one way is to not look
at the previous record, but actually sum the entire account
balance.
That way, no matter if it is an insert or an edit, the balance
will
always be correct. You do have After Edit and After Insert
triggers
that could run a stored procedure to update the customer balance.
In most cases, this would be recorded in the Customer Master
table in a field such as "CurrentBalance" and thus only
maintained
in the one spot, not in each transaction record. Using this
method
is usually straight forward and easily maintained.
Again, there are many ways to accomplish the same goal!
-Bob
--------------
Original message --------------
Bob
I have never done a trigger before and they
tend to
scare me. Would it be hard to keep the
rows sorted
so it always picked the "last" balance?
Also, what if
the user edited a row in the middle,
the trigger would have to update that balance and
update the balance for all the records below?
Marc
----- Original Message -----
Sent: Wednesday, February 09, 2005
1:56 PM
Subject: [RBG7-L] - Re: How can I
do this in RBase
One way (not a computed column though) is to use an After
Insert
trigger to run a stored procedure. The stored procedure
would
could obtain the previous balance and add the new transaction
to
it. (Substract, multiply or what ever you need)
-Bob
--------------
Original message --------------
> Hi
>
> Can
I have a formula for the Balance column that
> takes the
balance from the line above plus the
> charge from this line,
minus the payment
> and write off to get the new balance?
>
> I would love it if this could be a computed column.
>
> Custnum Charge Payment Write off Balance
> 11
$20 0 0 $20
> 11 $40 -$20 0 $40
> 11 $60 -$20 $10 $90
>
>
>
> Thanks
> Marc
>