-
Notifications
You must be signed in to change notification settings - Fork 939
Closed
Description
I would like to execute 2 queries in a single statement that affect two different tables.
This is what I have and it works:
field := "Something"
_, _ = dbpool.Exec(
context.Background(),
`DELETE FROM example.table1 WHERE oneColumn = ($1);`,
field,
)
_, _ = dbpool.Exec(
context.Background(),
`INSERT INTO example.table2 (otherColumn) values ($1);`,
field,
)
This is what I want:
field := "Something"
_, _ = dbpool.Exec(
context.Background(),
`DELETE FROM example.table1 WHERE oneColumn = ($1); INSERT INTO example.table2 (otherColumn) values ($1);`,
field,
)
And this is what I get:
"cannot insert multiple commands into a prepared statement"
It is not in my interest to have them run simultaneously I just want to simplify the code.
Metadata
Metadata
Assignees
Labels
No labels