Excited by the new versioning cabability of Sql server 2005 we are
resuming testing our products with it. The Borlad dbexpress driver seems
to give too many error...so we are testing with the
CORELABS dbexpsda.dll 3.0.5
In Delphi 7, iff the dataset is traversed with q.next, when the query is closed we sometimes get an error. Distilled down to basics, this code consistently errors:
q.sql.add('select sum(com_set_amount) as mysum ;
q.sql.add(' from cd_med ');
q.sql.add(' group by com_recipient_id ' );
q.open;
n:=0;
while not q.eof do
begin
q.next;
end;
q.close; // <------- ERRORS
Stepping down into that close code leads
way down in the memory manager function MFreeMem(),
specifically the line:
Result:=GlobalFreePtr(P);
Two days of trial and error research found that sum (and avg) when paired
with a "group by" are the problem. The following fixes the problem,
q.sql.add('select CAST(sum(com_set_amount) as numeric(14,2)) as mysum');
q.sql.add(' from cd_med ');
q.sql.add(' group by com_recipient_id ' );
q.open;
n:=0;
while not q.eof do
begin
q.next;
end;
q.close;
The two cases do return slightly differing Tfield types, but I dont see why
that should cause such a show-stopping error.
Just passing this on.
tonymeadors
Just passing on an oddity encountered (SQL Server 2005 w/dbexpress)
-
- Posts: 35
- Joined: Wed 28 Feb 2007 17:56