Here are the program and its makefile.

On Sun, 2005-11-06 at 17:26 -0600, John Goerzen wrote:
> On Sun, Nov 06, 2005 at 06:49:02PM +0100, Michal Palka wrote:
> > A program which imports HSQL.SQLite3 fails to link giving the following
> > error:
> 
> Please give the command you are using to compile, or the .cabal file
> if you are using that.
> 
> I have not seen this problem and I have built sqlite3 programs.  I
> suspect you are missing a -package declaration.
> 
> -- John
all: demo0 hsqltest simplehsqltest

demo0:
	ghc --make -o demo0 Demo0.hs

hsqltest:
	ghc --make -o hsqltest HSQLTest.hs

simplehsqltest:
	ghc --make -o simplehsqltest SimpleHSQLTest.hs

.PHONY: demo0 hsqltest simplehsqltest
{-# OPTIONS_GHC -package hsql #-}
module Main (Main.main) where

import System.IO
import Database.HSQL.SQLite3 hiding (disconnect)

main :: IO ()
main = do
  conn <- connect "test" ReadWriteMode

  (id, name) <- getStrings conn

  putStrLn $ "id = " ++ id ++ ", name = " ++ name

getStrings conn = do
  result <- query conn "SELECT * FROM test"
  fetch result
  id <- (getFieldValue result "id" :: IO String)
  name <- (getFieldValue result "name" :: IO String)
  return (id, name)

Reply via email to