Subject | Calculated Fields |
---|---|
Author | Laurie McIntosh |
Post date | 2006-07-27T11:18:15Z |
Hi all,
I'm struggling with calculated fields.
Let's say I've got an ib_query called ibq. It's got SQL like
SELECT MYDATE, COUNT(MYBOOK), COUNT (MYCALLS)
FROM FOO
Now, I want to calculate COUNT(MYBOOK) / COUNT(MYCALLS) for every record.
So I add a field like
MYCALC FLOAT
...to the calculated fields part of the ib_query.
I tried writing the onCalculateField method as if I was writing for an
ibquery but got all sorts of issues with that - along the lines of
ibq.FieldByName('MYCALC').AsFloat = ibq.FieldByName('MYBOOK').AsFloat
/ ibq.FieldByName('MYCALLS').AsFloat
Now I'm experimenting with
with AField do
if FieldName = 'MYCALC' then
AsFloat := ARow.ByName('MYBOOK').AsFloat /
ARow.ByName('MYBOOK').AsFloat;
end;
...which failed, as does
with AField do
if FieldName = 'P_MYCALC' then
AsFloat := ARow.GetColumnValue('MYBOOK').AsFloat /
ARow.GetColumnValue('MYBOOK').AsFloat;
This seems such a basic thing to do, I can't believe I can't do it...
quite ignoring the fact that it'd give me divide by zero issues... ideas?
Regards,
---=Laurie
I'm struggling with calculated fields.
Let's say I've got an ib_query called ibq. It's got SQL like
SELECT MYDATE, COUNT(MYBOOK), COUNT (MYCALLS)
FROM FOO
Now, I want to calculate COUNT(MYBOOK) / COUNT(MYCALLS) for every record.
So I add a field like
MYCALC FLOAT
...to the calculated fields part of the ib_query.
I tried writing the onCalculateField method as if I was writing for an
ibquery but got all sorts of issues with that - along the lines of
ibq.FieldByName('MYCALC').AsFloat = ibq.FieldByName('MYBOOK').AsFloat
/ ibq.FieldByName('MYCALLS').AsFloat
Now I'm experimenting with
with AField do
if FieldName = 'MYCALC' then
AsFloat := ARow.ByName('MYBOOK').AsFloat /
ARow.ByName('MYBOOK').AsFloat;
end;
...which failed, as does
with AField do
if FieldName = 'P_MYCALC' then
AsFloat := ARow.GetColumnValue('MYBOOK').AsFloat /
ARow.GetColumnValue('MYBOOK').AsFloat;
This seems such a basic thing to do, I can't believe I can't do it...
quite ignoring the fact that it'd give me divide by zero issues... ideas?
Regards,
---=Laurie