我正在尝试用Database.HDBC.PostgreSQL做一些类似的事情:
run c "update questions set deleted = now() where question_id in (?)" [toSql ids]其中,ids是Int。但是我得到了一个错误
No instance for (Data.Convertible.Base.Convertible [Int] SqlValue)如何使用HDBC填充in占位符?
发布于 2013-05-10 14:50:59
我不认为您可以避免动态构建查询,但您仍然可以避免SQL注入等。
import Control.Applicative ((<$), (<$>))
import Data.List (intersperse)
let query = "update questions set deleted = now() where question_id in ("
++ intersperse ',' ('?' <$ ids)
++ ")"
in run c query (toSql <$> ids)指向intersperse、<$>、<$文档的链接。
https://stackoverflow.com/questions/16472952
复制相似问题