[Libpqxx-general] Unnamed prepared statements vs PQexecParams

Trigve Siver trigves at yahoo.com
Wed Sep 30 10:47:01 UTC 2009


Hi,
as stated in subject I have some "C++ design" problem with unnamed prepared statements. Till now I was using "Session" (pqxx::connection wrapper) objects when preparing statements, executing statements, ... . (Transactions (pqxx::work) were created only in functions that used "Session" objects and weren't needed to be created outside the functions). But now I can create external "Transaction" object and need to execute some commands trough it. So I was thinking in changing my API like that: Function that need to create prepared statements will need only "Session" object, the one that execute statements will need only "Transaction" object. But as some time ago was suggested I've been using unnamed prepared statements as workaround for PQexecParams missing. But now I'll have to pass also "Session" object because only there I can create prepare statements, which isn't good.

I think this could be solved to by implementing PQexecParams (pqxx::prepare::invocation-style API would be fine) inside transaction class. I can handle this task if there will be interface specified and so.
Second workaround could be to add some functions to pqxx transaction classes for creating ONLY unnamed prepared statements.

Any thoughts?

thanks

Trigve



      


More information about the Libpqxx-general mailing list