[Haskell-cafe] Access to Oracle database from Haskell

Alistair Bayley alistair at abayley.org
Thu Jun 26 08:54:06 EDT 2008

> Now I can start GHCi with the example program you gave me. However I have to
> start with -lclntsh, otherwise symbol OCIEnvCreate cannot by found.
> I thought I do not need this option, because the installed Takusen package
> contains the library name:
> $ grep clntsh dist/installed-pkg-config
> extra-libraries: clntsh clntsh
> I wonder why it appears twice, because in dist/setup-config it exists
> only once:
>  extraLibs = ["clntsh"]

Yes, puzzling. I don't know why you need to say -lclntsh, because
that's the point of all of this Setup shenanigans: to get things set
up so that ghci works nicely.

That's why we have flags that expose/hide modules in the API: ghci has
a custom linker, and this tries to link everything in the library, and
of course this fails if you don't have the .ddl/.so installed for a
particular backend. ghc uses gnu ld to link, and this does not try to
link unused modules, so this works fine with the entire library API

Do you need to say -lclntsh when you use ghc to compile?

> Next step is to fetch real data from the database. But now I encounter new
> problems. If I write a real 'select' statement I get at best:
> Unexpected null in row 1, column 1.
> *** Exception: (unknown)

This looks like you are fetching a null value back with an iteratee
that does not expect nulls. We use Maybe to specify that a column in
the result-set can be null e.g.

  iter :: Int -> Maybe Int -> Maybe String -> IterAct [(Int, Maybe
Int, Maybe String)]

The first column must never contain null. If it does then you get the
"Unexpected null" exception.

> and at worst:
> 50001752
> *** glibc detected *** /usr/lib/ghc-6.8.2/ghc-6.8.2: free(): invalid
> pointer: 0x08d10065 ***
> ======= Backtrace: =========

If this continues, can you provide a test case for me?


More information about the Haskell-Cafe mailing list