[erlang-questions] Erlang and MySQL: ODBC, Column type not supported

Hanfei Shen <>
Sun May 1 16:32:34 CEST 2011


Dear all,

I'm a newbie programming in erlang. When I used ODBC to connect to a
MySQL database through Connector/ODBC (MyODBC), I got some error when
calling odbc:sql_query(Conn, "SELECT * FROM action"):

{error,"Column type not supported"}

Then I call odbc:describe_table(Conn, "action"), it returned:

{ok,[{"id",sql_integer},
     {"code",'ODBC_UNSUPPORTED_TYPE'},
     {"compliment_desc",'ODBC_UNSUPPORTED_TYPE'},
     {"status_desc",'ODBC_UNSUPPORTED_TYPE'},
     {"parameter",'ODBC_UNSUPPORTED_TYPE'},
     {"cause",'ODBC_UNSUPPORTED_TYPE'},
     {"disabled",sql_tinyint}]}

And desc the table in mysql client:
mysql> desc action;
+-----------------+--------------+------+-----+---------+----------------+
| Field           | Type         | Null | Key | Default | Extra          |
+-----------------+--------------+------+-----+---------+----------------+
| id              | int(11)      | NO   | PRI | NULL    | auto_increment |
| code            | varchar(255) | NO   |     | NULL    |                |
| compliment_desc | varchar(255) | NO   |     |         |                |
| status_desc     | varchar(255) | NO   |     |         |                |
| parameter       | varchar(255) | NO   |     |         |                |
| cause           | varchar(255) | NO   | UNI |         |                |
| disabled        | tinyint(1)   | NO   |     | 0       |                |
+-----------------+--------------+------+-----+---------+----------------+

It seems that Erlang ODBC driver does not support the mysql type
varchar? How can I use the database without touching the db schema?


Some details about the system env:

$ uname -a
Linux 2.6.36-gentoo-r8 #4 SMP Thu Apr 7 20:13:18 CST 2011 x86_64
Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz GenuineIntel GNU/Linux

$ erl
Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2]
[async-threads:0] [kernel-poll:false]

$ emerge -vp erlang
dev-lang/erlang-13.2.4  USE="doc kpoll odbc smp ssl -emacs -hipe -java
-sctp -tk -wxwidgets"

eshell> code:which(odbc).
"/usr/lib64/erlang/lib/odbc-2.10.7/ebin/odbc.beam"

$ mysql -V
mysql  Ver 14.14 Distrib 5.1.51, for pc-linux-gnu (x86_64) using readline 5.1

Server version: 5.1.51-log Gentoo Linux mysql-5.1.51

$ emerge -vp myodbc
dev-db/myodbc-5.1.6  USE="-debug -doc -qt4 -static"


Any help will be greatly appreciated.  Thanks in advance.
Sorry for my poor English, I'm not a native...

Best,

--
Hanfei



More information about the erlang-questions mailing list