Hello everyone,
> 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);
Sorry for the reply to an old message, but I think I should tell about
more convenient way of passing NULL values to prepared queries. I
recently had the same problem as Bert Hubert and while looking through
the pqxx sources, found that pqxx::prepare::invocation::setparam()
method has second argument 'bool nonnull', which specifies whether a
value should be treated as NULL-value or not.
You could use it like this:
d_work->prepared("insertEvent")(*parentID, parentID)(*live, live);
So when parentID pointer is NULL, 'nonnull' argument becomes false and
prepared statement receives NULL value.
Hope this will be helpful to someone.
--
Denis.
xmpp:[EMAIL PROTECTED]
_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general