Data type conversion error.

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Data type conversion error.

Post by jjeffman » Wed 10 Sep 2008 13:47

Hi support.

I have been getting troubles with the ODAC 6.50.xx version. It allows the TOraQuery componnent to deal with parameters of data types not suported by C++Builder like "Number" and "varchar". This behaviour is responsible for the raising of conversion errors at runtime. Bellow ther is an example of code that is raising this exception.

A TOraQuery with the SQL comand bellow:

Code: Select all

SELECT
  pri.name,
  DECODE(DECODE(SUBSTR(dv.current_status,1,1), null, SUBSTR(cn.normal_status,1,1), SUBSTR(dv.current_status,1,1)),'C','1','O','0','0') estado -- estado do logico
FROM
  &dbowner.oms_connectivity@&dblink cn,
  &dbowner.device_status@&dblink dv,
  &dbowner.&tb_primary@&dblink pri
WHERE
  pri.feeder_id = :alimentador AND
  pri.name = :nome_eqp AND
  cn.mslink = pri.mslink AND
  dv.mslink (+) = cn.mslink
The parameters were defined at design time with the proper ones (ftInteger and ftString ).

The code bellow sets the macro value :

Code: Select all

getLoad_Status->UnPrepare();

getLoad_Status->MacroByName("tb_primary")->Value = "OMS_BREAKER";
getLoad_Status->Prepare();
getLoad_Status->ParamByName("alimentador")->AsString = al->GetId();
getLoad_Status->ParamByName("nome_eqp")->AsString = nome_eqp2;
getLoad_Status->Open();
When the "Prepare" method is called the parameters data types are changed to "Varchar" instead of "String" and the "Conversion" error is raised on the "Open" method call.

Is there any solution ? The OraTool Add-in also do not support the 11g Client while ODAC components do !

Thank you very much.

Jayme Jeffman

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 11 Sep 2008 07:37

Try to replace the line

Code: Select all

getLoad_Status->ParamByName("alimentador")->AsString = al->GetId();
with the following line:

Code: Select all

getLoad_Status->ParamByName("alimentador")->AsInteger = al->GetId();
When you use the AsString property, DataType of the parameter is changed to ftString.

jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Post by jjeffman » Thu 11 Sep 2008 12:58

The problem is that the value returned by the "al->GetId()" method is something like "CAX1-105". So actually a string or varchar. I can not use AsInteger.

I've read in the history of revision of ODAC versions that a bug on the string parameter data type was solved on version 6.50.37. I've just installed it. I'll give it a try and check if the version upgrade solves the problem.

Thank you any way

jjeffman
Posts: 84
Joined: Tue 09 Nov 2004 12:22
Location: Porto Alegre-Rio Grande do Sul - Brazil

Problem solved!

Post by jjeffman » Fri 12 Sep 2008 13:48

The version upgrade has solved the problem.

The problem I have had before was related to the migration of applications made with older versions of ODAC. The default behaviour of the TOraQuery, or its ancestor where the Params property is defined, is set the parameter data type to the same data type of the column which is receiving the parameter data. So the parameter sometimes may have its data type set to Number, Varchar and others, which might not have a proper data type conversion.

Nowadays I always check if is there any parameter with the new data types and I exchange them to the old style.

Thank you very much. The application is running.

Post Reply