[Libpqxx-general] transactor select results?
Remco Post
remco at pipsworld.nl
Tue Dec 29 22:54:26 UTC 2009
On 29 dec 2009, at 23:38, Robert Backhaus-pqxx wrote:
>
>
> I see no difference between your use of public member variables to expose your query results or having a member function return a reference to private variables. I'm more or less tempted to hide all variables, allowing me to change implementation without changing my interface. Admitted, directly exposing the caller to a pqxx::result might not be a good idea either. My idea was to build a generic transactor that would work for about 90% of all of my database queries, and only build specific transactors for more complex matters.
>
> The problem is that the transactor framework creates a copy of your transactor and executes that. So in this code:
> mytractor T;
> T.query="Select * from table";
> C.perform(T);
> T.R[1],[0];
> R will _not_ contain data. The data is in a copy of T that was made just to do the transaction. This is done so that, on any error, the copy can be dropped, a new copy made, and the transaction retried, without causing any problems.
>
> Note that in my code, the output item was a pointer to the integer, not the integer itself.
Ah, I see, I think. Now, At least I understand why you use this pointer.
Maybe somebody should write some decent docs on libpqxx, IMHO a reference to 'the source' is no decent documentation. I do believe it's a very powerful library, but the lack of decent documentation really makes me think that maybe I should really not be using libpqxx at all.
I think that especially the transactor is avery confusing concept, that could really do with a bit of clarification. Should I be catching any exceptions in a transactor? If so, which ones? SInce the whole concept has been designed to hide certain errors from me, I'd think that I'll have to re-throw at least some exceptions? A properly (overly) documented transactor example would be so useful. I've been browsing the tests, reading the code. Hasn't clarified anything to me. The reference manual isn't very enlightening either, unfortunately.
--
Met vriendelijke groeten,
Remco Post
remco at pipsworld.nl
More information about the Libpqxx-general
mailing list