[Libpqxx-general] PQexecParams

Michael Akinde michael.akinde at met.no
Thu Apr 23 17:23:07 UTC 2009


Question:

How would you go about using prepared statements to load binary data into the database, without escaping the data and converting it to a string. There are no tests/examples showing how to do this, and the couple of attempts I have tried now don't work (0 bytes gets inserted into the db). If there is some obvious way of doing this, I am totally missing it.

Thanks,

Michael A.
Database Architect, http://wdb.met.no

----- "Jeroen Vermeulen" <jtv at xs4all.nl> wrote:

> 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
> _______________________________________________
> Libpqxx-general mailing list
> Libpqxx-general at pgfoundry.org
> http://pgfoundry.org/mailman/listinfo/libpqxx-general


More information about the Libpqxx-general mailing list