[Haskell-cafe] Access to Oracle database from Haskell

Alistair Bayley alistair at abayley.org
Tue Jun 24 10:55:09 EDT 2008

2008/6/24 Henning Thielemann <lemming at henning-thielemann.de>:
> (I remain on the list in order to fill the archive with information, others
> may need, too.)

As you wish.

> (Btw. Takusen should be split into
> several packages for all database backends because Cabal flags must not
> influence the package interface.)

I don't understand this (cabal flags must not influence package
interface). I thought that was the point of cabal flags? I wanted to
have a single package installation, and this seems like the best way.

> But on installation Cabal complains about missing /usr/oci directory.

When you run configure, you should get output that says:
Using Oracle: <path>

What is <path>?

The Setup.hs assumes the entire Oracle installation is under a single
root folder ($ORACLE_HOME); is this not true on Linux? If not, then we
will have to find some other way of locating the bin and include
folders. Perhaps we can do something like the Postgres installation,
where there is a program you can run which will print the include and
lib folders. That may mean a little hacking on Setup.hs, but there's
already a good example there for Postgres.

> Once I will get Takusen running with OCI - how would I use it? Is there a
> minimal example which connects to an Oracle database, performing a very
> simple query?

There's an example in the README.txt, which I've tweaked here for Oracle:

{-# OPTIONS -fglasgow-exts #-}
{-# OPTIONS -fallow-overlapping-instances #-}
module Main where
import Database.Oracle.Enumerator
import Control.Monad.Trans (liftIO)
main = flip catchDB reportRethrow $
  withSession (connect "user" "pswd" "dbname") (do
    let iter (s::String) (_::String) = result s
    result <- doQuery (sql "select 'Hello world.' from dual") iter ""
    liftIO (putStrLn result)


More information about the Haskell-Cafe mailing list