Hi,<br><br>The same on my windows 7 32 bit workstation.<br><br>Erlang R13B02 (erts-5.7.3)<br><br>4> code:which(odbc).<br>"d:/PROGRA~1/ERL57~1.3/lib/odbc-2.10.5/ebin/odbc.beam"<br><br>mysql odbc 5.1.8<br><br><br>
<br>I'm downloading the latest version of erlang (R14B02)...<br><br><br><div class="gmail_quote">2011/5/3 Hanfei Shen <span dir="ltr"><<a href="mailto:qqshfox@gmail.com">qqshfox@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>I had set up a fresh system and reproduce this problem successfully.<br>Here is something about my installations:<br><br>vm:<br>VirtualBox 4.0.6 r71416<br><br>gentoo:<br>livecd: install-amd64-minimal-20110317.iso<br>
stage: stage3-amd64-20110428.tar.bz2<br>portage: portage-20110424.tar.bz2<br><br>I only installed:<br><br>dev-db/mysql-5.1.51<div class="im"><br>dev-db/myodbc-5.1.6<br></div>dev-lang/erlang-13.2.4 USE="kpoll odbc smp"<br>
<br>table schema:<br>
<br>CREATE TABLE `action` (<br> `id` int(11) NOT NULL AUTO_INCREMENT,<br> `code` varchar(255) NOT NULL,<br> `compliment_desc` varchar(255) NOT NULL DEFAULT '',<br> `status_desc` varchar(255) NOT NULL DEFAULT '',<br>
`parameter` varchar(255) NOT NULL DEFAULT '',<br> `cause` varchar(255) NOT NULL DEFAULT '',<br> `disabled` tinyint(1) NOT NULL DEFAULT '0',<br> PRIMARY KEY (`id`),<br> UNIQUE KEY `index_action_on_cause` (`cause`)<br>
) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8;<div class="im"><br><br><br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex" class="gmail_quote">I see you are running on a 64 bit platform, maybe you can try it also on a 32 bit platform. Maybe<br>
you could try accessing the database from windows using the windows my-sql driver.<br></blockquote><br></div>I reproduced the problem on a 32bit server just right now...<br><br>I'll try it on a windows machine asap.<div>
<div></div><div class="h5"><br><br>
2011/5/3 Hanfei Shen <<a href="mailto:qqshfox@gmail.com" target="_blank">qqshfox@gmail.com</a>>:<br>> Hi,<br>><br>> Hmmmmmm... The unixODBC is already in my system, but I don't know how<br>> to use it...<br>
><br>
> I will setup a vm with fresh system tomorrow to reproduce the problem...<br>><br>> PS, could you figure out a name of ANOTHER ODBC-DRIVER which you mentioned?<br>><br>> 2011/5/3 Hanfei Shen <<a href="mailto:qqshfox@gmail.com" target="_blank">qqshfox@gmail.com</a>>:<br>
>> Hi,<br>>><br>>> I've tried <a href="https://github.com/dizzyd/erlang-mysql-driver" target="_blank">https://github.com/dizzyd/erlang-mysql-driver</a>, it works.<br>>><br>>> I'm installing unixodbc... Wait a minute. Thnx...<br>
>><br>>><br>>> 2011/5/3 Ingela Andin <<a href="mailto:ingela@erlang.org" target="_blank">ingela@erlang.org</a>>:<br>>>> Hi!<br>>>><br>>>> Well the best thing would be if you can provide me with a way to reproduce it.<br>
>>> Do you have the possibility to try another odbc-driver with your database?<br>>>><br>>>> Regards Ingela Erlang/OTP team - Ericsson AB<br>>>><br>>>><br>>>> 2011/5/2 Hanfei Shen <<a href="mailto:qqshfox@gmail.com" target="_blank">qqshfox@gmail.com</a>>:<br>
>>>> Hi,<br>>>>><br>>>>> I had changed the type from SQLINTEGER to SQLSMALLINT, but the problem<br>>>>> is still there...<br>>>>><br>>>>> (gdb) i func encode_data_type<br>
>>>> File odbcserver.c:<br>>>>> static void encode_data_type(SQLSMALLINT, SQLINTEGER, SQLSMALLINT, db_state *);<br>>>>><br>>>>> Breakpoint 1, encode_data_type (sql_type=-9, size=255,<br>
>>>> decimal_digits=0, state=0x7fffa5380210) at odbcserver.c:1396<br>>>>> 1396 switch(sql_type) {<br>>>>><br>>>>> Do you need any details?<br>>>>><br>>>>> 2011/5/2 Ingela Anderton Andin <<a href="mailto:ingela@erix.ericsson.se" target="_blank">ingela@erix.ericsson.se</a>>:<br>
>>>>> Hi!<br>>>>>><br>>>>>> Hanfei Shen wrote:<br>>>>>>><br>>>>>>> Hi Ingela,<br>>>>>>><br>>>>>>> Did you mean the value of variable "sql_type"?<br>
>>>>>><br>>>>>>><br>>>>>><br>>>>>> Yes.<br>>>>>><br>>>>>>> I tried to inspect it through gdb, setting a break on func<br>
>>>>>> encode_data_type. And then I got:<br>
>>>>>><br>>>>>>> Breakpoint 1, encode_data_type (sql_type=-9, size=255,<br>>>>>>> decimal_digits=0, state=0x7fffc657ec40) at odbcserver.c:1396<br>>>>>>> 1396 switch(sql_type) {<br>
>>>>>><br>>>>>>><br>>>>>><br>>>>>> Well that is defenetly not a good value. Looking at the code just now<br>>>>>> I noticed that<br>>>>>><br>
>>>>> encode_data_type defines sql_type as "SQLINTEGER sql_type" and it<br>>>>>> ought to be "SQLSMALLINT sql_type". If you change that does it fix your<br>>>>>> problem?<br>
>>>>><br>>>>>> Regards Ingela Erlang/OTP team - Ericsson AB<br>>>>>><br>>>>>><br>>>>>><br>>>>>>> 2011/5/2 Ingela Andin <<a href="mailto:ingela@erlang.org" target="_blank">ingela@erlang.org</a>>:<br>
>>>>>><br>>>>>>>><br>>>>>>>> Hi!<br>>>>>>>><br>>>>>>>> The erlang odbc application supports {sql-varchars, N} where N = 255<br>
>>>>>>> in your case. The return values<br>>>>>>>> you get suggest that the odbc-driver you have returns an unexpected<br>>>>>>>> column type.<br>>>>>>>><br>
>>>>>>> In the erlang odbc port program there is a switch that handles type<br>>>>>>>> when describing a coloumn that if we take out<br>>>>>>>> the handling code looks like this.<br>
>>>>>>><br>>>>>>>> switch(sql_type) {<br>>>>>>>> case SQL_CHAR:<br>>>>>>>> case SQL_VARCHAR:<br>>>>>>>> case SQL_WCHAR:<br>
>>>>>>> case SQL_WVARCHAR:<br>>>>>>>> case SQL_NUMERIC:<br>>>>>>>> case SQL_DECIMAL:<br>>>>>>>> case SQL_INTEGER:<br>>>>>>>> case SQL_TINYINT:<br>
>>>>>>> case SQL_SMALLINT:<br>>>>>>>> case SQL_REAL:<br>>>>>>>> case SQL_FLOAT:<br>>>>>>>> case SQL_DOUBLE:<br>>>>>>>> case SQL_BIT:<br>
>>>>>>> case SQL_TYPE_DATE:<br>>>>>>>> case SQL_TYPE_TIME:<br>>>>>>>> case SQL_TYPE_TIMESTAMP:<br>>>>>>>> case SQL_BIGINT:<br>>>>>>>> case SQL_BINARY:<br>
>>>>>>> case SQL_LONGVARCHAR:<br>>>>>>>> case SQL_VARBINARY:<br>>>>>>>> case SQL_LONGVARBINARY:<br>>>>>>>> case SQL_INTERVAL_MONTH:<br>
>>>>>>> case SQL_INTERVAL_YEAR:<br>>>>>>>> case SQL_INTERVAL_DAY:<br>>>>>>>> case SQL_INTERVAL_MINUTE:<br>>>>>>>> case SQL_INTERVAL_HOUR_TO_SECOND:<br>
>>>>>>> case SQL_INTERVAL_MINUTE_TO_SECOND:<br>>>>>>>> case SQL_UNKNOWN_TYPE:<br>>>>>>>> default: /* Will probably never happen */<br>>>>>>>> ei_x_encode_atom(&dynamic_buffer(state), "ODBC_UNSUPPORTED_TYPE");<br>
>>>>>>> break;<br>>>>>>>> }<br>>>>>>>><br>>>>>>>><br>>>>>>>> And you end up in the default clause which is very unexpected and the<br>
>>>>>>> root to your problem. If you can figur out<br>>>>>>>> what your driver returns for the ODBC C-API function SQLDescribeCol we<br>>>>>>>> could know if the driver is at fault or if the odbc-port program is.<br>
>>>>>>><br>>>>>>>> Regards Ingela Erlang/OTP team - Ericsson AB<br>>>>>>>><br>>>>>>>> 2011/5/1 Hanfei Shen <<a href="mailto:qqshfox@gmail.com" target="_blank">qqshfox@gmail.com</a>>:<br>
>>>>>>><br>>>>>>>>><br>>>>>>>>> Dear all,<br>>>>>>>>><br>>>>>>>>> I'm a newbie programming in erlang. When I used ODBC to connect to a<br>
>>>>>>>> MySQL database through Connector/ODBC (MyODBC), I got some error when<br>>>>>>>>> calling odbc:sql_query(Conn, "SELECT * FROM action"):<br>>>>>>>>><br>
>>>>>>>> {error,"Column type not supported"}<br>>>>>>>>><br>>>>>>>>> Then I call odbc:describe_table(Conn, "action"), it returned:<br>
>>>>>>>><br>>>>>>>>> {ok,[{"id",sql_integer},<br>>>>>>>>> {"code",'ODBC_UNSUPPORTED_TYPE'},<br>>>>>>>>> {"compliment_desc",'ODBC_UNSUPPORTED_TYPE'},<br>
>>>>>>>> {"status_desc",'ODBC_UNSUPPORTED_TYPE'},<br>>>>>>>>> {"parameter",'ODBC_UNSUPPORTED_TYPE'},<br>>>>>>>>> {"cause",'ODBC_UNSUPPORTED_TYPE'},<br>
>>>>>>>> {"disabled",sql_tinyint}]}<br>>>>>>>>><br>>>>>>>>> And desc the table in mysql client:<br>>>>>>>>> mysql> desc action;<br>
>>>>>>>><br>>>>>>>>> +-----------------+--------------+------+-----+---------+----------------+<br>>>>>>>>> | Field | Type | Null | Key | Default | Extra<br>
>>>>>>>> |<br>>>>>>>>><br>>>>>>>>> +-----------------+--------------+------+-----+---------+----------------+<br>>>>>>>>> | id | int(11) | NO | PRI | NULL | auto_increment<br>
>>>>>>>> |<br>>>>>>>>> | code | varchar(255) | NO | | NULL |<br>>>>>>>>> |<br>>>>>>>>> | compliment_desc | varchar(255) | NO | | |<br>
>>>>>>>> |<br>>>>>>>>> | status_desc | varchar(255) | NO | | |<br>>>>>>>>> |<br>>>>>>>>> | parameter | varchar(255) | NO | | |<br>
>>>>>>>> |<br>>>>>>>>> | cause | varchar(255) | NO | UNI | |<br>>>>>>>>> |<br>>>>>>>>> | disabled | tinyint(1) | NO | | 0 |<br>
>>>>>>>> |<br>>>>>>>>><br>>>>>>>>> +-----------------+--------------+------+-----+---------+----------------+<br>>>>>>>>><br>
>>>>>>>> It seems that Erlang ODBC driver does not support the mysql type<br>>>>>>>>> varchar? How can I use the database without touching the db schema?<br>>>>>>>>><br>
>>>>>>>><br>>>>>>>>> Some details about the system env:<br>>>>>>>>><br>>>>>>>>> $ uname -a<br>>>>>>>>> Linux 2.6.36-gentoo-r8 #4 SMP Thu Apr 7 20:13:18 CST 2011 x86_64<br>
>>>>>>>> Intel(R) Core(TM)2 Duo CPU E7500 @ 2.93GHz GenuineIntel GNU/Linux<br>>>>>>>>><br>>>>>>>>> $ erl<br>>>>>>>>> Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2]<br>
>>>>>>>> [async-threads:0] [kernel-poll:false]<br>>>>>>>>><br>>>>>>>>> $ emerge -vp erlang<br>>>>>>>>> dev-lang/erlang-13.2.4 USE="doc kpoll odbc smp ssl -emacs -hipe -java<br>
>>>>>>>> -sctp -tk -wxwidgets"<br>>>>>>>>><br>>>>>>>>> eshell> code:which(odbc).<br>>>>>>>>> "/usr/lib64/erlang/lib/odbc-2.10.7/ebin/odbc.beam"<br>
>>>>>>>><br>>>>>>>>> $ mysql -V<br>>>>>>>>> mysql Ver 14.14 Distrib 5.1.51, for pc-linux-gnu (x86_64) using<br>>>>>>>>> readline 5.1<br>
>>>>>>>><br>>>>>>>>> Server version: 5.1.51-log Gentoo Linux mysql-5.1.51<br>>>>>>>>><br>>>>>>>>> $ emerge -vp myodbc<br>>>>>>>>> dev-db/myodbc-5.1.6 USE="-debug -doc -qt4 -static"<br>
>>>>>>>><br>>>>>>>>><br>>>>>>>>> Any help will be greatly appreciated. Thanks in advance.<br>>>>>>>>> Sorry for my poor English, I'm not a native...<br>
>>>>>>>><br>>>>>>>>> Best,<br>>>>>>>>><br>>>>>>>>> --<br>>>>>>>>> Hanfei<br>>>>>>>>> _______________________________________________<br>
>>>>>>>> erlang-questions mailing list<br>>>>>>>>> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>>>>>>>>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
>>>>>>>><br>>>>>>>>><br>>>>>>><br>>>>>>><br>>>>>><br>>>>>><br>>>>> _______________________________________________<br>
>>>> erlang-questions mailing list<br>>>>> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>>>>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
>>>><br>>>><br>>><br>><br><br>
</div></div></blockquote></div><br>