sql_variant doesn't work

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
Dave
Posts: 3
Joined: Tue 01 Nov 2005 10:30
Contact:

sql_variant doesn't work

Post by Dave » Tue 01 Nov 2005 10:37

Hi all

I work with Delphi 2005 and the current dbExpress Drivers from Corelab. When I try to use the function below, then I get as result an exception. But when I just use the dbExpress-Drivers from Borland, then it works really nice.

I connect to a SQL 2000 Server and the result of the query is a sql_variant. The result should be something like 30000. I tried to get the result by Fields[0].AsString, but then it is 0.00003000.

Code: Select all

function Tultratlistbox.ExtractedMethod : Variant;
var
  ASQLQuery: TSQLQuery;
begin
  ASQLQuery := TSQLQuery.Create(nil);
  try
    with ASQLQuery do
    begin
      SQLConnection := SQLConnection1;
      SQL.Text := 'SELECT IDENT_CURRENT(''TABLE_NAME'')';
      Open;
      ShowMessage(VarToStr(Fields[0].Value));
      Result := Fields[0].Value;
      Close;
    end;
  finally
    { With }
    ASQLQuery.free;
  end;
end;
Any idea what could cause this problem?

Thanks alot...
Dave

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Tue 01 Nov 2005 16:18

Result of IDENT_CURRENT(...) is returned as DECIMAL, not sql_variant. Try to use AsBCD or AsInteger instead.

Dave
Posts: 3
Joined: Tue 01 Nov 2005 10:30
Contact:

Post by Dave » Wed 02 Nov 2005 09:18

I tried AsBCD and AsInteger as well, but the value that i recieved is .00035681 (using AsBCD) and 0 (using AsInteger) instead of 35681.

Dave
Posts: 3
Joined: Tue 01 Nov 2005 10:30
Contact:

Post by Dave » Wed 02 Nov 2005 09:34

I've downloaded the newest drivers 2.50.7, but I recieve the same result

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Thu 03 Nov 2005 07:15

We reproduced your problem and fixed it. This fix will be included in the next DbxMda build. It will be available in about one month.

This is Delphi2005 NormalizeBCD bug. You can see it in TCustomSQLDataSet.GetFieldData (unit SqlExpr).

As temporary solution try to cast IDENT_CURRENT to integer.

Post Reply