odbc help ( PATCH )
Vladimir Sekissov
svg@REDACTED
Fri Nov 29 17:52:42 CET 2002
Good day,
ingela> I am not familiar with this driver. But even if it does not implement
ingela> scrollable cursors it should have values for the driver attribute
ingela> SQL_DYNAMIC_CURSOR_ATTRIBUTES1 otherwhise it is not ODBC 3.0
ingela> compliant. Of course the value of that attribut will reflect that
ingela> scrollable cursors are not supported. And then the erlang ODBC will
ingela> work but return {error,driver_does_not_support_function} for some
ingela> functions. The patch that you propose is really a workaround for a bug
ingela> in the driver. So I think it is the driver that you should patch. The
ingela> function call SQLGetInfo could fail for other reasons than that
ingela> scrollable cursors are not supported example a memory allocation error
ingela> and that should be consider a disaster and the application should be
ingela> shut down.
As I mentioned native PostgresSQL ODBC is version 2.5 so it is
compliant only with ODBC 2 specification. If erlang ODBC can work well
with ODBC 2 drivers why it mustn't. My simple patch doesn't affect any
standard application functionality or behavior so it could be the user's
choice to use it with reduced to ODBC 2 abilities or not.
Best Regards,
Vladimir Sekissov
ingela> > olgeni> Looking for clues... I compiled the odbc application (R9B) using
ingela> > olgeni> libiodbc, installed odbcserver in priv/bin by hand, and found a
ingela> > olgeni> working DSN using the sample iodbc's odbctest application. I'm using
ingela> > olgeni> the postgresql driver (7.2.3).
ingela> > olgeni>
ingela> >
ingela> > The problem is that PostgreSQL ODBC driver is version 2.5 and knows
ingela> > nothing about scrollable cursors. This patch solves the
ingela> > problem with one small restriction. The followed function calls return
ingela> > {error,driver_does_not_support_function}:
ingela>
ingela> I am not familiar with this driver. But even if it does not implement
ingela> scrollable cursors it should have values for the driver attribute
ingela> SQL_DYNAMIC_CURSOR_ATTRIBUTES1 otherwhise it is not ODBC 3.0
ingela> compliant. Of course the value of that attribut will reflect that
ingela> scrollable cursors are not supported. And then the erlang ODBC will
ingela> work but return {error,driver_does_not_support_function} for some
ingela> functions. The patch that you propose is really a workaround for a bug
ingela> in the driver. So I think it is the driver that you should patch. The
ingela> function call SQLGetInfo could fail for other reasons than that
ingela> scrollable cursors are not supported example a memory allocation error
ingela> and that should be consider a disaster and the application should be
ingela> shut down.
ingela>
ingela> ---------- Quote from Microsoft doc: ---------------------
ingela>
ingela> "A driver must return a value for each of the information types
ingela> defined in the tables below. If an information type does not apply to
ingela> the driver or data source, the driver returns one of the values listed
ingela> in the following table.
ingela>
ingela> Format of *InfoValuePtr Returned value
ingela> Character string ("Y" or "N") "N"
ingela> Character string (not "Y" or "N") Empty string
ingela> SQLUSMALLINT 0
ingela> SQLUINTEGER bitmask or SQLUINTEGER binary 0L
ingela>
ingela>
ingela> [...]
ingela>
ingela> Information Types
ingela>
ingela> This section lists the information types supported by
ingela> SQLGetInfo. Information types are grouped categorically and listed
ingela> alphabetically. Information types that were added or renamed for
ingela> ODBC 3.x are also listed.
ingela>
ingela> Driver Information
ingela>
ingela> The following values of the InfoType argument return information
ingela> about the ODBC driver, such as the number of active statements, the
ingela> data source name, and the interface standards compliance level:
ingela>
ingela> SQL_ACTIVE_ENVIRONMENTS
ingela> SQL_GETDATA_EXTENSIONS
ingela> SQL_ASYNC_MODE
ingela> SQL_INFO_SCHEMA_VIEWS
ingela> SQL_BATCH_ROW_COUNT
ingela> SQL_KEYSET_CURSOR_ATTRIBUTES1
ingela> SQL_BATCH_SUPPORT
ingela> SQL_KEYSET_CURSOR_ATTRIBUTES2
ingela> SQL_DATA_SOURCE_NAME
ingela> SQL_MAX_ASYNC_CONCURRENT_STATEMENTS
ingela> SQL_DRIVER_HDBC
ingela> SQL_MAX_CONCURRENT_ACTIVITIES
ingela> SQL_DRIVER_HDESC
ingela> SQL_MAX_DRIVER_CONNECTIONS
ingela> SQL_DRIVER_HENV
ingela> SQL_ODBC_INTERFACE_CONFORMANCE
ingela> SQL_DRIVER_HLIB
ingela> SQL_ODBC_STANDARD_CLI_CONFORMANCE
ingela> SQL_DRIVER_HSTMT
ingela> SQL_ODBC_VER
ingela> SQL_DRIVER_NAME
ingela> SQL_PARAM_ARRAY_ROW_COUNTS
ingela> SQL_DRIVER_ODBC_VER
ingela> SQL_PARAM_ARRAY_SELECTS
ingela> SQL_DRIVER_VER
ingela> SQL_ROW_UPDATES
ingela> SQL_DYNAMIC_CURSOR_ATTRIBUTES1
ingela> SQL_SEARCH_PATTERN_ESCAPE
ingela> SQL_DYNAMIC_CURSOR_ATTRIBUTES2
ingela> SQL_SERVER_NAME
ingela> SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1
ingela> SQL_STATIC_CURSOR_ATTRIBUTES1
ingela> SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2
ingela> SQL_STATIC_CURSOR_ATTRIBUTES2
ingela> SQL_FILE_USAGE"
ingela>
ingela> --------- End quote ----------------
ingela>
ingela> > odbc:select(Conn, Pos, N) when Pos = {relative, P} | {absolute, P}
ingela> > odbc:prev(ConnectionReference)
ingela> >
ingela> > But most databases don't support back scrolling so we can live
ingela> > without it too. All other functionality is ok at least for me.
ingela> Well yes that how it suppose to work. If scrollable cursors are
ingela> supported you should be able to use them. But if not you can still use
ingela> the part of the API that don't use scrollable cursors.
ingela>
ingela> --
ingela> /m.v.h Ingela
ingela>
ingela> Ericsson AB - OTP team
ingela>
ingela>
ingela>
ingela>
ingela>
More information about the erlang-questions
mailing list