[erlang-bugs] ODBC R12B-5 Win32: Select statement doesn't work

Денис Артёмов art_den@REDACTED
Fri Nov 28 06:43:40 CET 2008


Hello everyone.

I tested how Erlang's ODBC works and find out that very simple example from Erlang ODBC documentation doesn't work. odbc:sql_query with SELECT statement, always returns {error,"Column type not supported"} if resulting columns contain varchar of char types. 

How to reproduce it:

============================================================================

    odbc:start(),
    
    ConnRes = odbc:connect("Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=test_db;User=root;Password=root;", []),
    io:format("ConnRes=~p~n", [ConnRes]),
    
    {ok, Ref} = ConnRes,
    
	CTres = odbc:sql_query(
    	Ref,
        "CREATE TABLE EMPLOYEE ("
        "NR         integer, "
      	"FIRSTNAME  varchar(32), "
        "LASTNAME   varchar(32), "
        "GENDER     char(1), "
      	"PRIMARY KEY(NR)"
        ")"
    ),
    
    io:format("CTres=~p~n", [CTres]),
    
    INSres = odbc:sql_query(Ref, "INSERT INTO EMPLOYEE VALUES(1, 'Jane', 'Doe', 'F')"),
    io:format("INSres=~p~n", [INSres]),
  
    SelectResult = odbc:sql_query(Ref, "SELECT * FROM EMPLOYEE"),
    io:format("SelectResult=~p~n", [SelectResult]),
    
    odbc:disconnect(Ref),

============================================================================

SelectResult will return {error,"Column type not supported"} for this example. 
If to select integer column:

    SELECT NR FROM EMPLOYEE

it will work properly then. 
If to select any char or varchar column:

    SELECT FIRSTNAME FROM EMPLOYEE

odbc:sql_query will return error then.

I tested it on Erlang R12B-5, WinXP x86 SP3
Tested databases:
    * Postgresql-8.3.3-2 and ODBC: PostgreSQL Unicode 8.03.04.00
    * Firebird Firebird-2.1.1.17910 and Firebird_ODBC 2.0.0.148
    * Mysql-5.1.30 and Mysql-connector-odbc-5.1.5

All databases were created with UTF8 character coding




More information about the erlang-bugs mailing list