question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prepare statement w/o values

See original GitHub issue

Hi!

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:closed
  • Created 12 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
brianccommented, Apr 19, 2011

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

0reactions
dvvcommented, Apr 20, 2011

In fact, I’ve found the current behavior quite well-suited. I can perfectly live with this “lazy-preparation” way. Thanks. Closing

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found