Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
-
- Posts: 9
- Joined: Fri 23 Mar 2012 04:38
- Location: Cape Town, South Africa
- Contact:
Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
I am porting an application to work with both Oracle and SQL Server. It seems like the best approach is to move from ODAC to UniDac, but I have hit a problem.
I am getting EDatabaseError ... Type mismatch for field '<fieldname>", expecting: Float actual: LargeInt.
I can't just change all my Float fields to LargeInts because some of the Floats are Actually floats.
Why does this problem exist and what do you suggest I do about it?
I am getting EDatabaseError ... Type mismatch for field '<fieldname>", expecting: Float actual: LargeInt.
I can't just change all my Float fields to LargeInts because some of the Floats are Actually floats.
Why does this problem exist and what do you suggest I do about it?
-
- Posts: 9
- Joined: Fri 23 Mar 2012 04:38
- Location: Cape Town, South Africa
- Contact:
Re: Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
Note that some of the Float fields are integers, but when adding them in the BDE or ODAC they come up automatically as Float fields.
Re: Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
Hello,
This behavior is due to different definition of field types in ODAC and UniDAC depending on the field size in a database.
To solve the issue, you should set mapping rules for the needed fields. For example, in ODAC, a NUMBER(18, 0) field in the database will be defined as TFloatField, and in UniDAC - as TLargeintField. To make behavior identical, set the following rule:
or set it in the UniQuery edit form on the DataTypeMapping tab.
This behavior is due to different definition of field types in ODAC and UniDAC depending on the field size in a database.
To solve the issue, you should set mapping rules for the needed fields. For example, in ODAC, a NUMBER(18, 0) field in the database will be defined as TFloatField, and in UniDAC - as TLargeintField. To make behavior identical, set the following rule:
Code: Select all
UniTable1.DataTypeMap.AddDBTypeRule(oraNumber, ftFloat, 18);
-
- Posts: 9
- Joined: Fri 23 Mar 2012 04:38
- Location: Cape Town, South Africa
- Contact:
Re: Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
Thanks Alex.
Must I do this for each field, or can I do it once for each application?
Regards
David
Must I do this for each field, or can I do it once for each application?
Regards
David
-
- Posts: 9
- Joined: Fri 23 Mar 2012 04:38
- Location: Cape Town, South Africa
- Contact:
Re: Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
Hi Alex
I found this
fAADataBase.DataTypeMap.AddDBTypeRule(oraNumeric, 11, rlAny, 0, 0, ftLargeint);
Can I use if for the database?
but where are OrNumeric, rlAny and ftLargeInt defined?
Regards
David
PS:
Here is my code:
TBaseDataObjectDAC = Class (TInterfacedObject)
private
{ Private Declarations }
fAADataBase: TUniConnection;
...
if not Assigned(fAADatabase) then
begin
fAADataBase:= TUniConnection.Create( nil );
fAADataBase.DataTypeMap.AddDBTypeRule(oraNumeric, 11, rlAny, 0, 0, ftLargeint);
//UniTable1.DataTypeMap.AddDBTypeRule(oraNumber, ftFloat, 18);
end;
I found this
fAADataBase.DataTypeMap.AddDBTypeRule(oraNumeric, 11, rlAny, 0, 0, ftLargeint);
Can I use if for the database?
but where are OrNumeric, rlAny and ftLargeInt defined?
Regards
David
PS:
Here is my code:
TBaseDataObjectDAC = Class (TInterfacedObject)
private
{ Private Declarations }
fAADataBase: TUniConnection;
...
if not Assigned(fAADatabase) then
begin
fAADataBase:= TUniConnection.Create( nil );
fAADataBase.DataTypeMap.AddDBTypeRule(oraNumeric, 11, rlAny, 0, 0, ftLargeint);
//UniTable1.DataTypeMap.AddDBTypeRule(oraNumber, ftFloat, 18);
end;
Re: Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
To apply mapping rules "globally", you should set them in TUniConnection - then the rule will be applied to all DataSets related to this UniConnection.
The oraNumber type is declared in the OraDataTypeMapUni module, the rlAny type - in MemDS, the ftLargeint type - in the DB.
The oraNumber type is declared in the OraDataTypeMapUni module, the rlAny type - in MemDS, the ftLargeint type - in the DB.
-
- Posts: 9
- Joined: Fri 23 Mar 2012 04:38
- Location: Cape Town, South Africa
- Contact:
Re: Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
Thanks Alex.
At the moment I am changing the relevant types to LongInts where applicable.
I'll keep you posted as to my progress.
Regards
David
At the moment I am changing the relevant types to LongInts where applicable.
I'll keep you posted as to my progress.
Regards
David
Re: Porting ODAC to UNIDAC: Type Mismatch problem with AsFloat and AsLargeInt
You are welcome. Feel free to contact us if you have any further questions.