microsoft / ODBC-Specification

Microsoft ODBC Specification
Other
121 stars 40 forks source link

How does an application interpret the results of a fetch in which a column was 'multiply-bound'? #104

Closed matthew-wozniczka closed 7 years ago

matthew-wozniczka commented 7 years ago

When multiple bindings were used for a given column for a single fetch (rowset size > 1), how does the application know which rows were fetched into which bindings?

One way I can see it working is for the driver to fill in the length indicator buffer for the 'interrupting column' (with SQL_DATA_UNAVAILABLE for all rows which have not yet been fetched [What to do about SQL_DATA_AT_FETCH?]) whenever a fetch is interrupted, so that the application can see which rows were fetched for that column into that binding. Subsequent len-ind-buffers would mark those rows as 'unavailable', so it would be up to the application to combine the information from all bindings to find which rows actually were missing that column.

It's kind of a hacky solution, since it forces the application to use a separate length indicator buffer every time a column is rebound (since the driver would overwrite the 'partial results' on entry to sqlfetch)

mikepizzo commented 7 years ago

Proposal: If rowset size > 1, you cannot change bindings during fetch.

matthew-wozniczka commented 7 years ago

That may avoid the issue, but if you can't rebind in multi-row fetches, is there much value in allowing binding of variant columns at all? It may simplify things by just forcing them to be retrieved with SQLGetData

Would you be able to unbind (but not rebind)? That would be useful if a variant column changed types on you in a way that the binding was no longer useful.

matthew-wozniczka commented 7 years ago

How would this interact with a SQL_TE_REPORT_ALL? If you were doing a multi-row fetch, and you get the type-exception on the first row, you would be able to get that cell of data with SQLGetData, but if you can't re-bind, I assume the driver would fetch the remaining rows into the original binding.

mikepizzo commented 7 years ago

Correct. Update applied to Getting Data During Fetch:

  1. If rowset size is 1, the app can update the binding information for the column only, which is used in the next call to SQLFetch/SQLFetchScroll.