From: Immanuel N. <i.n...@iu...> - 2007-10-22 20:10:06
|
Hello, I want to use the insert function and try to follow the guide from http://haskelldb.sourceforge.net/guide/insert.html My database has one table t1 with the following layout: +-------+----------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+----------+------+-----+---------+-------+ | c1 | int(11) | YES | | NULL | | | c2 | char(32) | YES | | NULL | | +-------+----------+------+-----+---------+-------+ Right now I am able to set up all such that I can send successfully a select query with e.g.: select = do withDB $ do t <- table t1 project (c1 << t!c1) But I fail with insert though I follow the instruction (of course adapted to my table layout) as presented on that website: testInsert = do withDB $ (\db -> insert db t1 ((c1 << constant 3) # (c2 << constant "foo"))) This yields the error: The lambda expression `\ db -> ...' has one argument, but its type `Query (Rel er)' has none In the second argument of `($)', namely `(\ db -> insert db t1 ((c1 << (constant 3)) # (c2 << (constant "foo"))))' In the expression: withDB $ (\ db -> insert db t1 ((c1 << (constant 3)) # (c2 << (constant "foo")))) In the expression: do withDB $ (\ db -> insert db t1 ((c1 << (constant 3)) # (c2 << (constant "foo")))) In fact the types are: (\db -> insert db t1 ((c1 << constant 3) # (c2 << constant "foo"))) :: Database -> IO () withDB :: (Database.HaskellDB.Database.GetRec er vr) => Query (Rel er) -> IO [Record vr] So, how does insert work correctly? Thanks, Immanuel |