[erlang-questions] MySQL and Erlang: ODBC , column type error

Robert Raschke <>
Mon May 11 18:16:59 CEST 2009


On Mon, May 11, 2009 at 4:53 PM, Carl McDade <> wrote:

> I am beginning to think this is a bug because the underscore does not
> have to be in the query. Its appearance in the result causes things to
> crash.
>
> 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee").
> ** exception error: no match of right hand side value
>                    {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town",
>                               "tel_no"],
>                              [{1,"carl","mcdade","m","hayward","23562366"},
>                               {2,"john","mason","m","san
> pablo","55214569"}]}
> 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee").
> ** exception error: no match of right hand side value {error,
>                                                       connection_closed}
> 7> Results = odbc:sql_query(Conn, "SELECT * FROM employee").
> ** exception error: no match of right hand side value {error,
>                                                       connection_closed}
> 8>
>
> The above causes werl.exe to crash and have to be restarted to get any
> response. You can only get a query response once before the underscore
> kills things.
>
> After removing the underscore from the column name the query runs as
> it should and as many times as it is called.
>
> Eshell V5.7.1  (abort with ^G)
> 1> application:start(odbc).
> ok
> 2> ConnString = "Driver={MySQL ODBC 5.1
> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;".
> "Driver={MySQL ODBC 5.1
> Driver};Server=localhost;Database=wordpress;User=root;Password=;Option=3;"
> 3> {ok, Conn} = odbc:connect(ConnString, []).
> {ok,<0.40.0>}
> 4> Results = odbc:sql_query(Conn, "SELECT * FROM employee").
> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town",
>           "telno"],
>          [{1,"carl","mcdade","m","hayward","23562366"},
>           {2,"john","mason","m","san pablo","55214569"}]}
> 5> Results = odbc:sql_query(Conn, "SELECT * FROM employee").
> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town",
>           "telno"],
>          [{1,"carl","mcdade","m","hayward","23562366"},
>           {2,"john","mason","m","san pablo","55214569"}]}
> 6> Results = odbc:sql_query(Conn, "SELECT * FROM employee").
> {selected,["NR","FIRSTNAME","LASTNAME","GENDER","town",
>           "telno"],
>          [{1,"carl","mcdade","m","hayward","23562366"},
>           {2,"john","mason","m","san pablo","55214569"}]}
> 7>
>
>
Umm, you are matching agains the bound name Results over and over. Remember
that you need a fresh name to capture new results.

And also, the odbc process handling the connection is linked to the shell
process, when you get an error, the shell is restarted and therefore the
link breakage causes your connection to go away as well.

Robby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090511/b182b3f8/attachment.html>


More information about the erlang-questions mailing list