File: transaction.hs

package info (click to toggle)
haskelldb 0.9.cvs.601-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 680 kB
  • ctags: 35
  • sloc: haskell: 4,392; sh: 1,792; makefile: 143
file content (29 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Database.HaskellDB

import TestConnect

import Control.Exception
import Dp037.Test_tb1

printRecord r = putStrLn $ show (r!c11) ++ " " ++ show (r!c12)

printRecords db = do
		  rs <- query db (table test_tb1)
		  mapM_ printRecord rs

testTrans db = do
	       insert db test_tb1 (c11 << constant 2 # c12 << constJust (-67))
	       fail "oops, that didn't work out"

handleErr io = catchJust userErrors io 
	        (\e -> putStrLn $ "caught nasty exception: " ++ e)

test db = do
	  putStrLn "before transaction:"
	  handleErr $ printRecords db
	  handleErr $ transaction db (testTrans db)
	  putStrLn "after transaction:"
	  handleErr $ printRecords db


main = argConnect test