Task #36 — fieldValue function only returns null after first null result
Attached to Project — OpenDBXBug Report | Medium | ||
Library | Normal | ||
Unconfirmed | 1.4.x | ||
No-one | Undecided | ||
Windows | |||
If a field from a table being read via OpenDBX has the value null, it appears that any further reads from the column involved will also return null, even if the correct value for that row is different. This problem occurred in the following code from a utility for moving data row-by-row from a query on one database to a table in another. while ((transfer_status = data.getResult()) != ODBX_RES_DONE) { while (data.getRow() != ODBX_ROW_DONE) { std::string insert_str("INSERT INTO "); insert_str.append(argv[optind+11]); insert_str.append(" VALUES ("); for (int counter=0;counter < data.columnCount();++counter) { if (counter > 0) insert_str.append(","); const char * value = data.fieldValue(counter); if (value != NULL) { insert_str.append("'"); string valueStr(value); string escapedValue; target.escape(value,escapedValue); insert_str.append(escapedValue); insert_str.append("'"); } else { insert_str.append("NULL"); } } insert_str.append(");"); Stmt s5 = target.create(insert_str); (...) |
Comments (6) | Attachments (0) | Related Tasks (0/0) | Notifications (1) | Reminders (0) | History |
Which database backend are you using?
Do you get the same behavior using a Linux system?
The code was using two backends, transferring data from SQL Server to PostgreSQL. The SQL Server interaction appears to cause the problem.
I don't have an appropriate Linux system available on which to test the behavior.
To clarify, I'm using mingw on Windows.
Which backend are you using for connecting to your MSSQL server? ODBC or mssql? The later one depends on FreeTDS and is mainly for Unix-like systems.
I'm using mssql as the backend, with FreeTDS.
This might be a bug in FreeTDS. Which version are you using?
Are you willing to debug into this issue? If yes, we should move to the mailing list as it allows us faster discussions about this topic.
Thank you
Yes, it could be a FreeTDS bug. I'm using version 0.82, which appears to be current.
I can get involved in debugging the issue. However, I'm not on the mailing list (yet).