Page 1 of 1

ODBC error in pfc\odbc\ and way forward

Posted: 4 Dec 2015 8:52
by Peter Muraya
Hi Thomas,
After making some minor change to my code, my application started to behave in a most unexpected way. The seemingly innocuous change I made was to access data by field name rather than by a column number, as I was not sure the order in which the columns were returned by a fetch. So, I made the change from e.g. :-

Code: Select all

X = getValueValue(1)

Code: Select all

X = getValueByName("test")
To cut a whole day of debugging short, I traced the error to the file in folder ..\pfc\odbc\. It is documented in the code piece below, where the variable ColumnName should have been ColumnNameOut.

Code: Select all

predicates     tryGetColumnNumberFromName : (string ColumnName) -> fieldIndex ColumnNumber   determ. clauses     tryGetColumnNumberFromName(ColumnName) = ColumnNumber :-         columnNameNumber_fact(string::toLowerCase(ColumnName), ColumnNumber),         !.       tryGetColumnNumberFromName(ColumnName) = ColumnNumber :-         Max = numResultCols(),         ColumnNumber = std::fromTo(columnNumberRead + 1, Max),             ColumnNameOut = colAttribute_string(ColumnNumber,   odbc_native::sql_desc_name),             assert(columnNameNumber_fact(string::toLowerCase(ColumnName),   ColumnNumber)), %The variable ColumnName should have been ColumnNameOut         string::equalCaseNeutral(ColumnName, ColumnNameOut),         !,         columnNumberRead := ColumnNumber.       tryGetColumnNumberFromName(_ColumnName) = _ :-         columnNumberRead := numResultCols(),         fail.  
I made the change and things were ok, but I now have a general question. I had to modify your protected code in order to continue. What would be the best cause of action to take when there's a need to change this protected code, short of waiting for the next build? I'm still using build 7501 as I had a few issues with your new build 7502. More of that later.

Posted: 4 Dec 2015 21:50
by Thomas Linder Puls
Thank you for tracking down this bug.

There are two ways of dealing with such a problem. You can change the installed file as ypou have now done.

Alternatively you update a copy of the file and place it in some directory which shadow the installation directory.

If you have your projects in <somewhere>\<projectX> you may for example create a directory called <somewhere>\fix and then call the file <somewhere>\fix\pfc\odbc\

Your projects should then have ..\fix as an include directory (before $(ProDir)), then the updated file will be included instead of the one from the installation.