Haskell Sqlite3挑战

时间:2018-08-27 17:54:28

标签: haskell sqlite

在真实世界的Haskell中,这是dbase模块HDBC的示例:

run conn "INSERT INTO test VALUES (?, ?)" [toSql 0, toSql "zero"]

问题是:VALUES(?,?)对我来说似乎是不好的做法,但是如果我为列命名:

run conn "INSERT INTO test VALUES (id, desc)" [toSql 0, toSql "zero"]

我得到一个错误:

*** Exception: SqlError {seState = "", seNativeError = 1, seErrorMsg = "prepare 34: INSERT INTO test VALUES (id,desc): no such column: id"}

奇怪,因为这些列实际上被命名为“ id”和“ desc”。也许是叛逆者?

run conn "INSERT INTO test VALUES ('id', 'desc')" [toSql 0, toSql "zero"]

但是结果如下:

*** Exception: SqlError {seState = "", seNativeError = -1, seErrorMsg = "In HDBC execute, received [SqlInt64 3,SqlString \"Newco\"] but expected 0 args."}

但是我真的很讨厌不得不问20个问号。你能帮我吗?

0 个答案:

没有答案