[Haskell-cafe] Access to Oracle database from Haskell
lemming at henning-thielemann.de
Thu Jun 26 08:40:18 EDT 2008
On Thu, 26 Jun 2008, Alistair Bayley wrote:
>> Try this version of configOracle in Setup.hs:
>> configOracle verbose buildtools = do
>> if not (sqlplusProgram `isElem` buildtools)
>> then return Nothing
>> else do
>> path <- getEnv "ORACLE_HOME"
>> info verbose ("Using Oracle: " ++ path)
>> makeConfig path libDir "oci/include"
>> where libDir = if isWindows then "bin" else "lib"
>> You'll also need to add this import:
>> import System.Environment (getEnv)
> Did you get a chance to try this? I'm quite keen to fix the
> non-Windows parts of the installation process, if I can.
I have replaced configOracle by
configOracle verbose buildtools = do
if not (sqlplusProgram `isElem` buildtools)
then return Nothing
path <- getEnv "ORACLE_HOME"
info verbose ("Using Oracle: " ++ path)
let (libDir, includeDir) =
then ("bin", "oci/include")
else ("lib", "/usr/include/oracle/10.2.0.4/client")
makeConfig path libDir includeDir
This is obviously a hack. We should get the Oracle include path from the
user, maybe via another environment variable or a custom Cabal option.
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
extraLibs = ["clntsh"]
Nevertheless I can start GHCi with the example program and I can see
'hello world'! Great - many thanks for the hints that led me to that
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)
and at worst:
*** glibc detected *** /usr/lib/ghc-6.8.2/ghc-6.8.2: free(): invalid
pointer: 0x08d10065 ***
======= Backtrace: =========
======= Memory map: ========
then GHCi quits.
> BTW, the location of your header files is still a puzzle. Oracle's docs:
> state that the header files shoulld be in $ORACLE_HOME/rdbms/public.
> But perhaps things are different for the Instant Client.
I don't know. I have just installed the RPMs and I expect that others will
do so as well.
More information about the Haskell-Cafe