[Libpqxx-general] PQexecParams

Jeroen Vermeulen jtv at xs4all.nl
Wed Apr 22 16:09:45 UTC 2009


Jeroen Vermeulen wrote:
> Trigve Siver wrote:
> 
>> I've question regarding PQexecParams. As stated in documentation "(PQexecParams) Submits a command to the server and waits for the result, with the
>> ability to pass parameters separately from the SQL command text.". Question is if support for this function could be added in pqxx (if it has sense since we can use prepared stmts (but not always we want to use prepared stms), ...). If yes I could make the patch.
> 
> Apparently it's the feature everyone's asking for this year!  I'll see 
> if I can implement this over the coming week.

Here's the simplest thing I can do: postgres lets you define a nameless 
prepared statement.  What's special about it is that you can re-define 
it without ever unpreparing it.

If I added support for that, you would use the prepared-statement API 
for this, except that you don't have pick a name and you don't have to 
unprepare the statement after use.  That's pretty much what PQexecParams 
does internally, as I recall.

The alternative is more work.  I'd have to reorganize things a bit, set 
up a "parameterized statements" module that the "prepared statements" 
module would build on top of.  There might be some incompatibility, as 
well as a bunch of extra code.  The only thing it would buy you would be 
that you could declare and pass each statement in a single invocation.


Jeroen


More information about the Libpqxx-general mailing list