Improper message of column not found

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

Improper message of column not found

Post by jjeffman » Thu 08 Jun 2017 19:35

Hello,

I am using ODAC 9.7.26 on C++Builde 6.0.

My application connects to an Oracle server through a VPN and sometimes I receive an error message saying that some column was not found in the DataSet.

I have just one program line in the whole application which makes mention of the column (TIPOTARIFA):

Code: Select all

          
if(!ORA->getConfMedicao->FieldByName("TIPOTARIFA")->IsNull){
            if( ORA->getTarifaGrupo->Locate("NUMABNT", 
                    FMedicao->Config->TipoTarifa, TLocateOptions()) )
              ValueListEditor1->Values["AROW"+IntToStr(ValueListEditor1->RowCount-1)] =
                ORA->getTarifaGrupo->FieldByName("NOME_TARIFA")->AsString;
          }

The TOraDataSet getConfMedicao must be opened at the point the column is mentioned, it was previously opened.

I can not find out nor understand why this exception is being raised. It does not happen every time and I could not reproduce the error running the application on the IDE.

Any clue on this question ?

Best regards.
Jayme Jeffman

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Improper message of column not found

Post by MaximG » Fri 16 Jun 2017 10:12

Please make sure that you are working with the same Oracle schema while your application is running. If it is so, try immediately after the error occurs, refer to the TIPOTARIFA field using any independent tool (for example, using SQL*Plus)

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

Re: Improper message of column not found

Post by jjeffman » Fri 16 Jun 2017 13:22

Thank you very much for answering me.

I have already had this error before on other tables but at that time the TOraDataSet was not Active.

I have only one Oracle schema and the field TIPOTARIFA do exist in the schema table and also in the SQL Select command.

I am connecting to a far database through a VPN network. The error only happens on the first time the application uses the data set, after that it doesn't happen anymore.

Is there a chance that the TDataSet::FieldByName method have been called before the data set is actually opened ?

I have changed the code to protect this situation :

Code: Select all

if(ORA->getConfMedicao->Active && !ORA->getConfMedicao->FieldByName("TIPOTARIFA")->IsNull)
I am afraid the Oracle response time over the network might be the cause of the problem, because the first time the SQL command is performed the response time is greater than the subsequents.

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Improper message of column not found

Post by MaximG » Mon 19 Jun 2017 10:48

We cannot determine whether the FieldByName method is called before or after opening the corresponding dataset without the source code of your project. Change the corresponding check as follows:

Code: Select all

if (ORA→getConfMedicao→Active) …
to make sure that no operations are executed with dataset in case of its inactivity. Note that ODAC provides a special work mode in case of unstable connection: https://www.devart.com/odac/docs/?unstable_network.htm

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

Re: Improper message of column not found

Post by jjeffman » Mon 19 Jun 2017 14:21

Thank you very much for answering me.

Your answer led me to check the code.

You're right! Although I have added a check to ensure that the data set is already opened, it might not be enough, because I could be dealing with the previous selected record of the data set instead of the current.

The code under analysis is in the event handler of a TreeView item change event, which calls a Locate method on the data set, and open it before if closed, so the code is misplaced. I will move it to the data set OnDataChange event handler.

Thank you very much.

Best regards.

Jayme Jeffman

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Improper message of column not found

Post by MaximG » Mon 19 Jun 2017 14:40

We are glad you have localized the problem. Please contact us concerning ODAC usage.

Post Reply