Ok, pretend I never wrote the below. I switched to the trunk of libpqxx (it
might be a wise idea to mention the location of the subversion repository
somewhere on the wiki where it is easy to find), and the problem was gone.
This allowed me to separate out the various () calls to the invocation.
Thanks!
On Tue, Jun 19, 2007 at 04:27:39PM +0200, bert hubert wrote:
> Dear libpqxx people, Jeroen.
>
> Many thanks for the great library. It is so good that it has influenced me
> to choose PostgreSQL, even though I am more of a MySQL person. The c++
> library makes a real difference!
>
> To speed up repetitive queries, I'm using a prepared query that has 3 fields
> that each may or not be NULL. Prepared queries can deal with NULL fields, so
> that is good.
>
> However, I'm having a hard time trying to pass a NULL at runtime. Viz:
>
> d_work->prepared("insertEvent")(1)(2)(3);
>
> This is valid, and works, and so do the 7 other combinations:
>
> d_work->prepared("insertEvent")()()();
> d_work->prepared("insertEvent")()()(1);
> d_work->prepared("insertEvent")()(1)(1);
> ...
>
> However, I'd hate to have to write out these 8 separate forms, so what I try
> to do is:
>
> pqxx::prepare::invocation invo = d_work->prepared("insertEvent");
> if(parentID)
> invo(*parentID);
> else
> invo();
>
> if(live)
> invo(*live);
> else
> invo();
>
> etc. But this very much doesn't work, it says it doesn't know of a ''
> prepared event. I think d_work->prepared doesn't really return a
> pqxx::prepare::invocation but some kind of megacomplicated descendant of it?
>
> Is there another way to pass a NULL? Something like this would be cool:
>
> d_work->prepared("insertEvent")(parentID ? *parentID : NULL)(live ? *live
> : NULL)()
>
> Sadly this doesn't work:
>
> d_work->prepared("insertEvent")(parentID ? *parentID : )(live ? *live : )()
>
> Any help would be appreciated!
>
> Bert
>
> --
> http://www.PowerDNS.com Open source, database driven DNS Software
> http://netherlabs.nl Open and Closed source services
--
http://www.PowerDNS.com Open source, database driven DNS Software
http://netherlabs.nl Open and Closed source services
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general