[Haskell-cafe] HDBC-ODBC and SqlValues

Tim Docker twd2 at dockerz.net
Thu Apr 8 00:08:44 EDT 2010


I'm experimenting with haskell and relational databases. I have
successfully coupled unixodbc + freetds + hdbc-odbc, and can make
trivial queries. However, I'm surprised at the result types:

$ ghci
GHCi, version 6.10.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude> c <-  Database.HDBC.ODBC.connectODBC
     "DSN=xxxxx;UID=xxxxx;PWD=xxxx"
Loading package syb ... linking ... done.
Loading package base-3.0.3.1 ... linking ... done.
Loading package array-0.2.0.0 ... linking ... done.
Loading package containers-0.2.0.1 ... linking ... done.
Loading package bytestring-0.9.1.4 ... linking ... done.
Loading package old-locale-1.0.0.1 ... linking ... done.
Loading package old-time-1.0.0.2 ... linking ... done.
Loading package mtl-1.1.0.2 ... linking ... done.
Loading package utf8-string-0.3.5 ... linking ... done.
Loading package time-1.1.4 ... linking ... done.
Loading package convertible-1.0.9 ... linking ... done.
Loading package HDBC-2.2.4 ... linking ... done.
Loading package HDBC-odbc-2.2.3.0 ... linking ... done.
Prelude> Database.HDBC.quickQuery c "select 1+3" []            
[[SqlByteString "4"]]
Prelude>

Why do I see an SqlByteString returned, rather than a numeric type?

Taking a closer look at the HDBC-ODBC implementation it would appear
that data will always be returned as SqlByteString, or as SqlNull.

Is this the intended behaviour, or just a sign of an incomplete
implementation of the ODBC driver? It would certainly seem possible for
the ODBC driver to return more specific types.

Tim



More information about the Haskell-Cafe mailing list