[Haskell-cafe] Access to Oracle database from Haskell

Henning Thielemann lemming at henning-thielemann.de
Wed Jun 25 04:59:38 EDT 2008

On Tue, 24 Jun 2008, Alistair Bayley wrote:

>>> 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" ?

It doesn't output the Oracle path. :-(

>> 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?

Yes, I have successfully connected to a database with sqlplus, already.

> 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
> Takusen.cabal:
>  > 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.

I don't get an error. sqlplus is in $ORACLE_HOME/bin, but the RPM package 
also sets a link from /usr/bin/sqlplus to $ORACLE_HOME/bin, thus 'sqlplus' 
is in the $PATH also without $ORACLE_HOME. (But sqlplus cannot be started 
until the LD_LIBRARY_PATH is extended to Oracles libraries.)

>> $ echo $ORACLE_HOME
>> /usr/lib/oracle/
>> $ ls $ORACLE_HOME
>> 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)
>    Exposed-modules:
>        Database.Oracle.Enumerator
>      , Database.Oracle.OCIConstants
>      , Database.Oracle.OCIFunctions
>    Build-Tools: sqlplus
>    If os(windows)
>      Extra-Libraries: oci
>    Else
>      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.

They got installed to:
  That is, they are not in $ORACLE_HOME. :-(

>> $ runhaskell Setup.hs configure --user -f oracle
>> Configuring Takusen-0.8.2...
> Here, I would expect to see "Using Oracle: /usr/lib/oracle/"

It does not tell me. :-(

> 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.

Takusen-0.8.2.conf and dist/installed-pkg-config contain the same.
They contain

include-dirs: /usr/oci

independent from my setting of ORACLE_HOME. As I said, I cannot manually 
fix dist/installed-pkg-config, because it gets overwritten by 'Setup 

More information about the Haskell-Cafe mailing list