Subject | IBOQuery doesn't work when parentheses are present |
---|---|
Author | mspencewasunavailable |
Post date | 2006-12-27T22:39:31Z |
I'm using 4.7 Beta 12. Here's a code fragment:
q := TIBOQuery.Create(Application);
try
with q do
begin
DatabaseName := StartupDM.dbCompany.DatabaseName;
SQL.Add('select C."Last Name", C.ID, A."Invoice #",
A."Date", '
+ ' A."Total", A."Tax", A."Paid", '
+ ' cast((A."Paid" * A."Tax") / A."Total" '
+ ' as numeric(12,2)) as "Tax
Received" '
+ ' from CUST C, ARINV A '
+ ' where C.ID = A."Acc ID" '
+ ' and A."Invoice #" <> '''' '
+ ' and A."Date" between :sdate and :edate '
+ ' order by A."Date", A."Invoice #"');
Params.ParamByName('sdate').AsDate := SDATE;
Params.ParamByName('edate').AsDate := EDATE;
RecordCountAccurate := True;
Active := True;
end;
At this point q.recordcount is always 0.
If I then take this query exactly as it appears in the IBMonitor
log, remove the extra spaces and fill in the params by hand, I get
this:
select C."Last Name", C.ID, A."Invoice #", A."Date",
A."Total", A."Tax", A."Paid",
cast((A."Paid" * A."Tax") / A."Total" as numeric(12,2)) as "Tax
Received"
from cust c, arinv a where C.ID = A."Acc ID"
and A."Invoice #" <> ''
and A."Date" between '01 Jan 2006' and '27 Dec 2006'
ORDER BY A."Date" ASC, A."Invoice #" ASC
Which returns 25 records.
It appears that if I change the lines with the cast from this:
+ ' cast(A."Paid" * A."Tax" / A."Total" '
+ ' as numeric(12,2)) as "Tax
Received" '
to this
+ ' A."Paid" * A."Tax" / A."Total" '
+ ' as "Tax
Received" '
the query works in my program. If I introduce parentheses, like
this:
+ ' (A."Paid" * A."Tax") / A."Total" '
+ ' as "Tax
Received" '
it stops working. This seems fishy to me.
Michael D. Spence
Mockingbird Data Systems, Inc.
q := TIBOQuery.Create(Application);
try
with q do
begin
DatabaseName := StartupDM.dbCompany.DatabaseName;
SQL.Add('select C."Last Name", C.ID, A."Invoice #",
A."Date", '
+ ' A."Total", A."Tax", A."Paid", '
+ ' cast((A."Paid" * A."Tax") / A."Total" '
+ ' as numeric(12,2)) as "Tax
Received" '
+ ' from CUST C, ARINV A '
+ ' where C.ID = A."Acc ID" '
+ ' and A."Invoice #" <> '''' '
+ ' and A."Date" between :sdate and :edate '
+ ' order by A."Date", A."Invoice #"');
Params.ParamByName('sdate').AsDate := SDATE;
Params.ParamByName('edate').AsDate := EDATE;
RecordCountAccurate := True;
Active := True;
end;
At this point q.recordcount is always 0.
If I then take this query exactly as it appears in the IBMonitor
log, remove the extra spaces and fill in the params by hand, I get
this:
select C."Last Name", C.ID, A."Invoice #", A."Date",
A."Total", A."Tax", A."Paid",
cast((A."Paid" * A."Tax") / A."Total" as numeric(12,2)) as "Tax
Received"
from cust c, arinv a where C.ID = A."Acc ID"
and A."Invoice #" <> ''
and A."Date" between '01 Jan 2006' and '27 Dec 2006'
ORDER BY A."Date" ASC, A."Invoice #" ASC
Which returns 25 records.
It appears that if I change the lines with the cast from this:
+ ' cast(A."Paid" * A."Tax" / A."Total" '
+ ' as numeric(12,2)) as "Tax
Received" '
to this
+ ' A."Paid" * A."Tax" / A."Total" '
+ ' as "Tax
Received" '
the query works in my program. If I introduce parentheses, like
this:
+ ' (A."Paid" * A."Tax") / A."Total" '
+ ' as "Tax
Received" '
it stops working. This seems fishy to me.
Michael D. Spence
Mockingbird Data Systems, Inc.