Just passing on an oddity encountered (SQL Server 2005 w/dbexpress)

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
tonymeadors
Posts: 35
Joined: Wed 28 Feb 2007 17:56

Just passing on an oddity encountered (SQL Server 2005 w/dbexpress)

Post by tonymeadors » Wed 28 Feb 2007 18:05

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

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Fri 02 Mar 2007 13:30

We couldn't reproduce the problem.
Please supply us with the script for creating your database objects.

Post Reply