microsoft / ODBC-Specification

Microsoft ODBC Specification
Other
122 stars 40 forks source link

Allow setting the (expected) type for a column #126

Closed mikepizzo closed 7 years ago

mikepizzo commented 7 years ago

If a column has an expected type (say, int for an age column) but an instance has a different type (say, the string "ancient"), the driver raises SQL_METADATA_CHANGED and changes the type for the column in the IRD from int to string. The application then sees that this instance was a string and uses SQLGetData to read the value. However, if the column is again an int on the next column (as expected), then the application will again get the SQL_METADATA_CHANGED when the type of the IRD changes back to int.

One way to mitigate this would be to allow the application to set the IRD (back) to the "expected" type, in which case the type exception wouldn't occur on the next row.

mikepizzo commented 7 years ago

Added: The application can attempt to set the type information in the IRD to an "expected" type. Drivers SHOULD accept setting the IRD for variable type columns but MAY return an error if the type information for the column is a known, fixed type.