sql - PostgreSQL "?" argument placeholder does not work for "WITH" -
i trying use ?
in following way (i use in golang generate query, seems not go dependent):
with tmp(name, enabled) ( values(?, ?),(?, ?) ) update table_groups set enabled = (select enabled tmp table_groups.name=tmp.name) table_groups.name in (select name tmp)
getting:
syntax error @ or near ","
if substitute ?
in above statement concrete values, works fine. there problem using ?
with
, how around it? thanks.
go doesn't support @ of box.
you can use jmoiron/sqlx if want functional
example using sqlx (from docs):
var levels = []int{4, 6, 7} query, args, err := sqlx.in("select * users level in (?);", levels) // sqlx.in returns queries `?` bindvar, can rebind our backend query = db.rebind(query) rows, err := db.query(query, args...)
Comments
Post a Comment