Using postgres 9.3
, go 1.6
I've been trying to use transactions with the go
pq
library.
// Good
txn, _ := db.Begin()
txn.Query("UPDATE t_name SET a = 1")
err := txn.Commit() // err is nil
// Bad
txn, _ := db.Begin()
txn.Query("UPDATE t_name SET a = $1", 1)
err := txn.Commit() // Gives me a "unexpected command tag Q" error
// although the data is committed
For some reason, when I execute a Query
with parameters, I always get an unexpected command tag Q
error from the Commit()
. What is this error (what is Q?) and why am I getting it?
I believe this is where the error is created.
db.Begin()
andtxn.Query()
; possibly one of those has an error that may shed some light on the issue before thetxn.Commit()
– Lymphangial