On Thu, June 15, 2006 22:56, [EMAIL PROTECTED] wrote:

> string query ="SELECT binarydata FROM usager_tbl where usagerid=";
> s<<query<<abonneid<<" AND cdid="<<cdid<<" AND
superviseurid="<<superviseurid<<";"<<endl;
> s.flush();

[...]

> result R( T.exec(query) );

The ";" and endl at the end of the query are really not necessary.  I
don't think they are causing any problems here, but you may want to leave
them out, just in case.

The problem seems to happen where you insert your first int into your
query.  The code looks fine to me, but have you tried printing your query
to cout to see what it really contains?  For instance, if usagerid is a
large number like 12345, your locale may render it as "12.345".  So then
your query would not say "usagerid=12345" but "usagerid=12.345"!

This is why it's better to use libpqxx's to_string() functions for these
conversions: they ignore the locale and use the format that the database
prefers.  Alternatively, you could try clearing the locale setting for s:

  s.imbue(locale("C"))

...before you start inserting text into s.


> I don't know if it's the right way for getting bytea values but this is
> not the problem yet ...

For bytea values, use the binarystring class and, in the latest libpqxx
versions, the transaction's esc_raw() functions.  (In older libpqxx
versions, use pqxx::escape_binary()).


Jeroen


_______________________________________________
Libpqxx-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/libpqxx-general

Reply via email to