odbc help ( PATCH )

Ingela Anderton <>
Fri Nov 29 17:03:05 CET 2002


Vladimir Sekissov wrote:
> Hi,
> 
> olgeni> Looking for clues... I compiled the odbc application (R9B) using
> olgeni> libiodbc, installed odbcserver in priv/bin by hand, and found a
> olgeni> working DSN using the sample iodbc's odbctest application. I'm using
> olgeni> the postgresql driver (7.2.3).
> olgeni> 
> 
> The problem is that PostgreSQL ODBC driver is version 2.5 and knows
> nothing about scrollable cursors. This patch solves the
> problem with one small restriction. The followed function calls return
> {error,driver_does_not_support_function}:

I am not familiar with this driver. But even if it does not implement
scrollable cursors it should have values for the driver attribute
SQL_DYNAMIC_CURSOR_ATTRIBUTES1 otherwhise it is not ODBC 3.0
compliant.  Of course the value of that attribut will reflect that
scrollable cursors are not supported. And then the erlang ODBC will
work but return {error,driver_does_not_support_function} for some
functions. The patch that you propose is really a workaround for a bug
in the driver. So I think it is the driver that you should patch.  The
function call SQLGetInfo could fail for other reasons than that
scrollable cursors are not supported example a memory allocation error
and that should be consider a disaster and the application should be
shut down.

---------- Quote from Microsoft doc: ---------------------

"A driver must return a value for each of the information types
defined in the tables below. If an information type does not apply to
the driver or data source, the driver returns one of the values listed
in the following table.

Format of *InfoValuePtr                         Returned value
   Character string ("Y" or "N")                "N"
   Character string (not "Y" or "N")            Empty string
   SQLUSMALLINT                                 0
   SQLUINTEGER bitmask or SQLUINTEGER binary    0L

   
   [...]

   Information Types

   This section lists the information types supported by
   SQLGetInfo. Information types are grouped categorically and listed
   alphabetically. Information types that were added or renamed for
   ODBC 3.x are also listed.

   Driver Information

   The following values of the InfoType argument return information
   about the ODBC driver, such as the number of active statements, the
   data source name, and the interface standards compliance level:

   SQL_ACTIVE_ENVIRONMENTS
                                                 SQL_GETDATA_EXTENSIONS
   SQL_ASYNC_MODE
                                                 SQL_INFO_SCHEMA_VIEWS
   SQL_BATCH_ROW_COUNT
                                                 SQL_KEYSET_CURSOR_ATTRIBUTES1
   SQL_BATCH_SUPPORT
                                                 SQL_KEYSET_CURSOR_ATTRIBUTES2
   SQL_DATA_SOURCE_NAME
                                                 SQL_MAX_ASYNC_CONCURRENT_STATEMENTS
   SQL_DRIVER_HDBC
                                                 SQL_MAX_CONCURRENT_ACTIVITIES
   SQL_DRIVER_HDESC
                                                 SQL_MAX_DRIVER_CONNECTIONS
   SQL_DRIVER_HENV
                                                 SQL_ODBC_INTERFACE_CONFORMANCE
   SQL_DRIVER_HLIB
                                                 SQL_ODBC_STANDARD_CLI_CONFORMANCE
   SQL_DRIVER_HSTMT
                                                 SQL_ODBC_VER
   SQL_DRIVER_NAME
                                                 SQL_PARAM_ARRAY_ROW_COUNTS
   SQL_DRIVER_ODBC_VER
                                                 SQL_PARAM_ARRAY_SELECTS
   SQL_DRIVER_VER
                                                 SQL_ROW_UPDATES
   SQL_DYNAMIC_CURSOR_ATTRIBUTES1
                                                 SQL_SEARCH_PATTERN_ESCAPE
   SQL_DYNAMIC_CURSOR_ATTRIBUTES2
                                                 SQL_SERVER_NAME
   SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1
                                                 SQL_STATIC_CURSOR_ATTRIBUTES1
   SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2
                                                 SQL_STATIC_CURSOR_ATTRIBUTES2
   SQL_FILE_USAGE"

--------- End quote   ----------------

> odbc:select(Conn, Pos, N) when Pos = {relative, P} | {absolute, P}
> odbc:prev(ConnectionReference)
> 
> But most databases don't support back scrolling so we can live
> without it too. All other functionality is ok at least for me.
Well yes that how it suppose to work. If scrollable cursors are
supported you should be able to use them. But if not you can still use
the part of the API that don't use scrollable cursors.

-- 
/m.v.h Ingela

Ericsson AB - OTP team









More information about the erlang-questions mailing list