microsoft / ODBC-Specification

Microsoft ODBC Specification
Other
121 stars 40 forks source link

Does SQL_ATTR_LENGTH_EXCEPTION_BEHAVIOR apply to fixed-length source types? #107

Open matthew-wozniczka opened 7 years ago

matthew-wozniczka commented 7 years ago

The current documentation for SQLGetData states:

SQLGetData cannot be used to return fixed-length data in parts. If SQLGetData is called more than one time in a row for a column containing fixed-length data, it returns SQL_NO_DATA for all calls after the first.

Does this carry over to the SQL_LE_REPORT feature?

The current text of section _3.8.1 (SQL_ATTR_LENGTH_EXCEPTIONBEHAVIOR) mentions 'string' & 'binary', but it's not clear if it's referring to the source type or the target type (or both?).

If not, I assume that truncations involving a fixed-length source type will still cause errors (... which may then be intercepted via SQL_ATTR_TYPE_EXCEPTION_BEHAVIOR = SQL_TE_REPORT_EXCEPTION)?

mikepizzo commented 7 years ago

First off, I don't think that the fixed-length comment in SQLGetData was intended to apply to fixed length character/binary columns; only to types that can't reasonably be retrieved in parts (i.e., bool, int, float, etc.)

So if you have a column of type Char(256), you should be able to call SQLGetData to retrieve the data, say, 50 characters at a time.

SQL_ATTR_LENGTH_EXCEPTION_BEHAVIOR should only apply to types that can be fetched in parts. So, again, you should be able to bind a Char(256) to a buffer of that holds 50 characters, and with SQL_ATTR_LENGTH_EXCEPTION_BEHAVIOR = SQL_LE_REPORT you can get SQL_MORE_DATA and fetch the remainder using SQLGetData.

So SQL_ATTRL_LENGTH_EXCEPTION_BEHAVIOR should apply to fixed- or variable-length string or binary data.

mikepizzo commented 7 years ago

Driver Manager shouldn't care about this setting, but make sure it doesn't affect an ARD consistency checks (i.e., that SQL_ATTR_LENGTH_EXCEPTION_BEHAVIOR is something other than the default for a non-string and non-binary type.

mikepizzo commented 7 years ago

Clarified in spec that SQLGetData can be used with any character or binary type, as can SQL_ATTR_LENGTH_EXCEPTION.

Dean, please verify this is the current supported behavior in the Driver Manager.