Board index » delphi » Interesting Delphi Database Field Problem

Interesting Delphi Database Field Problem

Quote
In article <31BDC4B4.2...@infonet.co.za> Simeon Lifschitz <sim...@infonet.co.za> writes:
>From: Simeon Lifschitz <sim...@infonet.co.za>
>Subject: Interesting Delphi Database Field Problem
>Date: Tue, 11 Jun 1996 22:10:44 +0300
>Hi
>I am tring to put a formulae into a database. There are possiblly 100 formula's
>such as Salary * 1.15 + Overtime where salary and overtime are values to be found in a database.
>Now when I write something like Table1Salary.value * 1.15 + Table1Overtime.value as a record in 1 database
>say called table2, how do I get the value of this as in the code I cant say
>  strtoint("Table1Salary.value * 1.15 + Table1Overtime.value"), ie is there any way to dereference a string
>or a database variable.
>sorry for the confusion
>any help will be appreciated

i think you need some sort of parser / formula evaluator - i think there are
suitable -ish things on the DSP

hth

boris

 

Re:Interesting Delphi Database Field Problem


Hi

I am tring to put a formulae into a database. There are possiblly 100 formula's
such as Salary * 1.15 + Overtime where salary and overtime are values to be found in a database.

Now when I write something like Table1Salary.value * 1.15 + Table1Overtime.value as a record in 1 database
say called table2, how do I get the value of this as in the code I cant say
  strtoint("Table1Salary.value * 1.15 + Table1Overtime.value"), ie is there any way to dereference a string
or a database variable.

sorry for the confusion

any help will be appreciated

thanks

Re:Interesting Delphi Database Field Problem


Quote
Simeon Lifschitz <sim...@infonet.co.za> wrote:
>Now when I write something like Table1Salary.value * 1.15 + Table1Overtime.value as a record in 1 database
>say called table2, how do I get the value of this as in the code I cant say
>  strtoint("Table1Salary.value * 1.15 + Table1Overtime.value"), ie is there any way to dereference a string
>or a database variable.

Sounds like you're looking for a runtime macro processor a la Clipper or
Foxpro. They, being p-code can do this without much fanfare. Delphi is not
a p-code system. There is no interpreter parsing each line as it runs, so
my best guess is that you're out of luck.

I think your only hope is to parse the lines and do a field name match to
figure out where the data is supposed to come from. Maybe put the field
names into an array (actually I suppose they're already in an array - look
up FieldDefs), and match your parsed field name to each item of the array
to get the field number. Then use the field number to get the value.
Cumbersome, but maybe doable. Sorry, but I just don't have the energy
right now to try it.

Alan

Re:Interesting Delphi Database Field Problem


Quote
Simeon Lifschitz wrote:

> Hi

> I am tring to put a formulae into a database. There are possiblly 100 formula's
> such as Salary * 1.15 + Overtime where salary and overtime are values to be found in a database.

> Now when I write something like Table1Salary.value * 1.15 + Table1Overtime.value as a record in 1 database
> say called table2, how do I get the value of this as in the code I cant say
>   strtoint("Table1Salary.value * 1.15 + Table1Overtime.value"), ie is there any way to dereference a string
> or a database variable.

> sorry for the confusion

> any help will be appreciated

> thanks

I'm not sure to understand your problem. Why don't let the SQL parser do
it? It's easier, faster and platform independent. Eg.:
Select Salary, Salary*1.15+Overtime as BigSalary FROM Salarytable

Hope this helps.

--
-------------------------------------
Robert Cerny - application designer & developer
Neosys Ltd. Ljubljana
Email: robert.ce...@neosys.xrs.si

Other Threads