From 6325993048c42fe5cdb27357f13d294c6bf70ae2 Mon Sep 17 00:00:00 2001 From: Arnaud Benhamdine Date: Fri, 26 Feb 2016 10:17:17 +0100 Subject: [PATCH] Clarify that multi statements param queris are not supported, see #946 --- Prepared-Statements.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Prepared-Statements.md b/Prepared-Statements.md index 5aab558..e7eebef 100644 --- a/Prepared-Statements.md +++ b/Prepared-Statements.md @@ -38,6 +38,25 @@ client.query(SQL`select name from user where id=${userId} and password=${passwor If you want it as a module, take a look at [sql-template-strings](https://www.npmjs.com/package/sql-template-strings). +#### Multi-statement parameterized queries #### + +Multi-statement parameterized queries are currently not supported by postgres. + +For example, the following statements will throw an error : + +```javascript +client.query('SELECT $1; SELECT $1;', [123], callback); +``` +```javascript +client.query({ text: 'SELECT $1; SELECT $1;' }, [123], callback); +``` +```javascript +error: cannot insert multiple commands into a prepared statement +... +``` + +A workaround is to do 2 separate queries and using whatever type of async flow control to dispatch them. + ##Prepared Statements## A prepared statement lets postgres plan the statement so that each execution takes advantage of the