Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 13 total
Thread Calculated fields or SQL
Sun, Jan 25 2009 7:21 AMPermanent Link

David Darlison
I am converting an app from BDE to DBISAM.
Just a quick question.
My old app used a fair amount of fields that were fkcalculated (SubTotals etc.).
Should I stick with these or use SQL to calculate the fields? Performance over
a wan is important.
Sun, Jan 25 2009 7:49 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

David,

Do you mean executing SQL from inside OnCalcFields? If that is what you
mean, there is no general rule - it depends on the calculations you have
to do for each one of the calculated fields.
If the value can be calculated using only values from other fields in
the same record, then there is, in general, no gain in using SQL. On the
other hand, if you have to use values from other tables or from other
records in the same table, then SQL would be certainly better. Over slow
connections, the general idea is to minimize the amount of data you need
to retrieve for each record.

--
Fernando Dias
[Team Elevate]
Mon, Jan 26 2009 2:35 AMPermanent Link

David Darlison
Fernando Dias wrote:

David,

Do you mean executing SQL from inside OnCalcFields? If that is what you
mean, there is no general rule - it depends on the calculations you have
to do for each one of the calculated fields.
If the value can be calculated using only values from other fields in
the same record, then there is, in general, no gain in using SQL. On the
other hand, if you have to use values from other tables or from other
records in the same table, then SQL would be certainly better. Over slow
connections, the general idea is to minimize the amount of data you need
to retrieve for each record.

Thanks Fernando,
The values to be calculated in this case are:
A line item price item.ExtPrice(part.price * item.qty)
An order table total which is the sum
of all line items.
Mon, Jan 26 2009 2:48 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

David


Something you don't indicate is f/s or c/s. Since you mention wan I'm assuming c/s

Roy Lambert
Mon, Jan 26 2009 7:26 AMPermanent Link

David Darlison
Roy Lambert wrote:


<<Something you don't indicate is f/s or c/s. Since you mention wan I'm assuming c/s>>

Yes, c/s
Mon, Jan 26 2009 10:27 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

David,

> The values to be calculated in this case are:
> A line item price item.ExtPrice(part.price * item.qty)
> An order table total which is the sum
> of all line items.

For the order total you should use SQL.
For the other value I'm not sure I understand - do you mean item.price
is obtained calculating part.price * item.qty, where "part" and "item"
are tables ?

--
Fernando Dias
[Team Elevate]
Mon, Jan 26 2009 11:27 AMPermanent Link

David Darlison
Fernando Dias wrote:

>For the other value I'm not sure I understand - do you mean item.price
is obtained calculating part.price * item.qty, where "part" and "item"
are tables ?
Yes, exactly that.

--
Fernando Dias
[Team Elevate]
Mon, Jan 26 2009 11:35 AMPermanent Link

"Robert"

"David Darlison" <dave@ukweigh.net> wrote in message
news:E9A411C3-6E3E-403A-B56E-FF9B66187D1B@news.elevatesoft.com...
> Fernando Dias wrote:
>
>>For the other value I'm not sure I understand - do you mean item.price
> is obtained calculating part.price * item.qty, where "part" and "item"
> are tables ?
> Yes, exactly that.
>

If you need to hit other tables, definitely use SQL.

Robert

Mon, Jan 26 2009 11:46 AMPermanent Link

David Darlison
"Robert" wrote:

>If you need to hit other tables, definitely use SQL.
My problem with that is I am using cached updates so the item has to be posted
before any SQL calculations can be made.
eg
Post the item (save qty & price)
ApplyUpdate
Edit the item
Run SQL to calculate qty * price

or is there an easier way.

David
Mon, Jan 26 2009 12:00 PMPermanent Link

Fernando Dias

Team Elevate Team Elevate

David,

> My problem with that is I am using cached updates so the item has to be posted
> before any SQL calculations can be made.

If the "Parts" table is small, you can also use a lookup field to get
parts.price, with "LookupCache" set to true.
Plese note that setting "LookupCache" to true is only an advantage if
there is a small number of records in the parts table.

--
Fernando Dias
[Team Elevate]
Page 1 of 2Next Page »
Jump to Page:  1 2
Image