problem data type COUNT SQLSERVER
Posted: Fri 16 May 2008 12:53
Hello,
I'm a software engineer and my company want an application that must be work correctly on Oracle and SQLServer databases (with total transparency).
For this reason, My company buy our DBExpress products for Oracle and SQL Server (dbexpoda.dll / dbexpsda.dll).
In some cases, the applicattion need to create a calculated data field on TSQLClientDataSet, and then is obligatory to create the all fields on the dataset with the respective type.
The problem is when create a field to store the result for a COUNT clausule, the field is type ftFloat when using Oracle database and is type ftInteger when using SQL Server database. Is possible to resolve this problem, and that the type will be the same?
I’m sending a sample where you can see how to create the field and how to send the query.
function CreateFieldToDataSet (DataSet: TDataSet; Name: string; DataCalc: TFieldKind; FieldType: TFieldType): TField;
var
Field: TField;
begin
Field := nil;
case FieldType of
ftInteger: Field := TIntegerField.create(nil);
ftFloat: Field := TFloatField.Create(nil);
end;
Field.FieldName := Name;
Field.FieldKind := DataCalc;
Field.SetFieldType(FieldType);
Field.DataSet := DataSet;
Result := Field;
end;
The sentence to get the field value (over TSQLClientDataSet) is:
SELECT COUNT(*) AS TOTAL FROM TEST
Thanks
I'm a software engineer and my company want an application that must be work correctly on Oracle and SQLServer databases (with total transparency).
For this reason, My company buy our DBExpress products for Oracle and SQL Server (dbexpoda.dll / dbexpsda.dll).
In some cases, the applicattion need to create a calculated data field on TSQLClientDataSet, and then is obligatory to create the all fields on the dataset with the respective type.
The problem is when create a field to store the result for a COUNT clausule, the field is type ftFloat when using Oracle database and is type ftInteger when using SQL Server database. Is possible to resolve this problem, and that the type will be the same?
I’m sending a sample where you can see how to create the field and how to send the query.
function CreateFieldToDataSet (DataSet: TDataSet; Name: string; DataCalc: TFieldKind; FieldType: TFieldType): TField;
var
Field: TField;
begin
Field := nil;
case FieldType of
ftInteger: Field := TIntegerField.create(nil);
ftFloat: Field := TFloatField.Create(nil);
end;
Field.FieldName := Name;
Field.FieldKind := DataCalc;
Field.SetFieldType(FieldType);
Field.DataSet := DataSet;
Result := Field;
end;
The sentence to get the field value (over TSQLClientDataSet) is:
SELECT COUNT(*) AS TOTAL FROM TEST
Thanks