ODBC error in pfc\odbc\odbcStatement.pro and way forward
Posted: 4 Dec 2015 8:52
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. :-to
To cut a whole day of debugging short, I traced the error to the file odbcStatement.pro in folder ..\pfc\odbc\. It is documented in the code piece below, where the variable ColumnName should have been ColumnNameOut.
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.
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")
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.