prepare statement w/o values
See original GitHub issueHi!
How do I prepare a statement w/o binding values and executing it, just for future use as named query? The absense of values
key in configuration parameters causes unhandled error
event so far
TIA, –Vladimir
Issue Analytics
- State:
- Created 12 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
PREPARE statement - IBM
The PREPARE statement creates an executable SQL statement, called a prepared statement ... The statement string is the value of the specified host...
Read more >Prepared statement - Wikipedia
A prepared statement takes the form of a pre-compiled template into which constant values are substituted during each execution, and typically use SQL...
Read more >PREPARE Statement - MariaDB Knowledge Base
The PREPARE statement prepares a statement and assigns it a name, stmt_name , by which to refer to the statement later. Statement names...
Read more >MySQL 5: Prepared statement syntax and Dynamic SQL
PREPARE associates an identifier with the statement, stmt , wich acts as a handle to refer to the statement and the corresponding execution...
Read more >Using Prepared Statements - JDBC Basics - Oracle Help Center
This JDBC Java tutorial describes how to use JDBC API to create, insert into, update, and query tables. You will also learn how...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okey dokey…thanks for the awesome gist. I see the issue.
With node-postgres the first time you issue a named query it is parsed, bound, and executed all at once. Every subsequent query issued on the same connection with the same name will automatically skip the “parse” step and only rebind and execute the already planned query.
Currently node-postgres does not support a way to create a named, prepared query and not execute the query. This feature is supported within libpq and the client/server protocol (used by the pure javascript bindings), but I’ve not directly exposed it in the API. I thought it would add complexity to the API without any real benefit. Since named statements are bound to the client in which they are created, if the client is disconnected and reconnected or a different client is returned from the client pool, the named statement will no longer work (it requires a re-parsing).
Here’s an example of how it works currently:
https://github.com/brianc/node-postgres/blob/master/test/integration/client/prepared-statement-tests.js#L18
In fact, I’ve found the current behavior quite well-suited. I can perfectly live with this “lazy-preparation” way. Thanks. Closing