[Haskell-cafe] Access to Oracle database from Haskell

Alistair Bayley alistair at abayley.org
Tue Jun 24 17:35:56 EDT 2008

>> 2008/6/24 Henning Thielemann <lemming at henning-thielemann.de>:
>> When you run configure, you should get output that says:
>> Using Oracle: <path>
>> What is <path>?
> I don't get these questions.

Sorry. I was really asking (not very clearly): what is the output from
"runhaskell Setup.hs configure -foracle" ? You've answered that below.

> Ah, I must have set ORACLE_HOME for the Takusen installation ... should be
> documented. However in my case, this doesn't change the path used by
> Takusen's Setup/install.

Well, you don't actually need it set for the Takusen install (it
doesn''t use it). But $ORACLE_HOME/bin should be in your path. And it
needs to contain the executable sqlplus. Can you run sqlplus? It looks
as though you don't have it.

If sqlplus is not in my path then I get this error in the configure
step, because I have specified sqlplus as a buildtool in

  > setup configure -foracle
  Configuring Takusen-0.8.2...
  setup: sqlplus is required but it could not be found.

Note: sqlplus isn't really needed to build; this is just a validation
step, to check you have $ORACLE_HOME/bin in your path.

> $ echo $ORACLE_HOME
> /usr/lib/oracle/
> bin  lib
> $ ll $ORACLE_HOME/lib
> ...
> I assume that libociei.so is the library I need.

Actually it's libclntsh.so. You need to change the oracle section in
Takusen.cabal to this:

  If flag(oracle)
      , Database.Oracle.OCIConstants
      , Database.Oracle.OCIFunctions
    Build-Tools: sqlplus
    If os(windows)
      Extra-Libraries: oci
      Extra-Libraries: clntsh

Your $ORACLE_HOME installation looks fairly normal, if somewhat
minimal. I would normally expect to see sqlplus, and maybe some other
executables, like tnsping. And a folder $ORACLE_HOME/oci/include,
which contains the OCI header files. Perhaps you could also install
the sqplus and SDK packages, as Lanny Ripple suggested, although I
suspect they may not be strictly necessary, as you can apparently
successfully compile, as evidenced below.

> $ runhaskell Setup.hs configure --user -f oracle
> Configuring Takusen-0.8.2...

Here, I would expect to see "Using Oracle: /usr/lib/oracle/"

After setup configure you can say:
  $ runhaskell Setup.hs register --gen-pkg-config

and then take a look at the generated Takusen-0.8.2.conf. Check the
library-dirs and include-dirs fields.


More information about the Haskell-Cafe mailing list