SQLStrings.jl icon indicating copy to clipboard operation
SQLStrings.jl copied to clipboard

ERROR: cannot insert multiple commands into a prepared statement

Open lkovac22 opened this issue 3 years ago • 1 comments

This may not be an issue, rather just a question. Using LibPQ when I try to execute multiple statements separated by semicolon as one execution (SQLStrings.prepare + LibPQ.execute) I am getting an error [error | LibPQ]: SyntaxError: ERROR: cannot insert multiple commands into a prepared statement

Example:

INSERT INTO test.two_columns VALUES($1, $2);
INSERT INTO test.two_columns VALUES($3, $4)
  $1 = 3
  $2 = 4
  $3 = 4
  $4 = 3

At the same time, LibPQ.execute of simple string

"INSERT INTO test.two_columns VALUES(3, 4);
INSERT INTO test.two_columns VALUES(4, 3)"

is successful.

Is this a way how it has to be and each statement has to be executed separately, or there could be something we can do to make it happen? Thank you.

lkovac22 avatar Nov 16 '22 07:11 lkovac22

This looks like a limitation (or design decision) of postgres itself so you should split these into separate statements.

c42f avatar Oct 14 '24 10:10 c42f