我剛開始一個新項目,並想在開始時使用HaskellDB。我創建了一個數據庫2列:haskelldb中的部分SQL插入
create table sensor (
service text,
name text
);
..found如何做基本HaskellDB機械(ohhh..the文檔),想要做一次插入。然而,我想要做的部分插入(也應該是多列),是這樣的:
insert into sensor (service) values ('myservice');
翻譯成HaskellDB:
transaction db $ insert db SE.sensor (SE.service <<- (Just $ senService sensor))
不過...。那根本不起作用。如果我按不同的順序指定列名,那也不起作用,這也不是很好。有沒有辦法在haskelldb中進行部分插入?
錯誤代碼我得到的是 - 當我剛插入不同的列(「名稱」)作爲第一個:
Couldn't match expected type `SEI.Service'
against inferred type `SEI.Name'
Expected type: SEI.Intsensor
Inferred type: Database.HaskellDB.HDBRec.RecCons
SEI.Name (Expr String) er
When using functional dependencies to combine
Database.HaskellDB.Query.InsertRec
(Database.HaskellDB.HDBRec.RecCons f (e a) r)
(Database.HaskellDB.HDBRec.RecCons f (Expr a) er),
etc..
當我做「服務」作爲第一個 - 也只有 - 場,我得到:
Couldn't match expected type `Database.HaskellDB.HDBRec.RecCons
SEI.Name
(Expr String)
(Database.HaskellDB.HDBRec.RecCons
SEI.Time
(Expr Int)
(Database.HaskellDB.HDBRec.RecCons
SEI.Intval (Expr Int) Database.HaskellDB.HDBRec.RecNil))'
against inferred type `Database.HaskellDB.HDBRec.RecNil'
(我有表一對夫婦的其他列) 這看起來真像「設計」,不幸的是:(
這將有助於瞭解您看到的錯誤以及爲某些中間表達式計算的類型。 – 2010-08-27 19:47:53