Convert negative numbers with TADOQuery

I have a huge problem with TADOQuery :

This is my SQL:

 select cast(-10 as number(9)) foo, -10 bar from dual 

Instead of TBCDField, a TIntegerField will be created when you add the "foo" field, because at that moment the type is changing:

 procedure TCustomADODataSet.InternalInitFieldDefs; if (F.Type_ = adNumeric) and (F.NumericScale = 0) and (F.Precision < 10) then FieldType := ftInteger; 

function:

 function TCustomADODataSet.GetFieldData(Field: TField; Buffer: Pointer; NativeFormat: Boolean): Boolean; 

We are not considering the signal at this moment:

  ftAutoInc, ftInteger: Integer(Buffer^) := lVal; 

tagVariant value for TIntegerField:

(14, 32768, 0, 0, 10, 10, 10, 1.4012984643e-44, 4.9406564584e-323, True, 10, 0.001, 4.9406564584e-323, $ A, $ A, $ A, $ A, $ A , $ A, $ A, $ A, $ A, $ A, $ A, $ A, $ A '', $ A, $ A, $ A, $ A, $ A, # 10, 10, 10, 10 , 10, $ A, $ A, $ A, $ A, $ A)

which is the same for TBCDField:

(14, 32768, 0, 0, 10, 10, 10, 1.4012984643e-44, 4.9406564584e-323, True, 10, 0.001, 4.9406564584e-323, $ A, $ A, $ A, $ A, $ A , $ A, $ A, $ A, $ A, $ A, $ A, $ A, $ A '', $ A, $ A, $ A, $ A, $ A, # 10, 10, 10, 10 , 10, $ A, $ A, $ A, $ A, $ A)

The foo value will be 10, and the bar value will be -10.

This is mistake?

Have a WorkAround?

Was this fixed?

I tested using the OLEDB provider for Oracle and the Oracle Provider for OLEDB. All tests were performed using Delphi 6.

+4
source share
1 answer

I don’t know if I understood correctly, but try this way:

 select cast(replace(-10,'-','') as number(9)) foo, -10 bar from dual; 
0
source

All Articles