[Libpqxx-general] adopting stateless cursor
Madden, Don (DCOR)
don.madden at smithsdetection.com
Tue Jul 21 17:19:00 UTC 2009
Hi,
I am a new user of libpqxx and I am using version 3.0.3 of libpqxx. I
am creating a "stateless cursor" below and then use then in later
transactions, i will be adopting this stateless cursor. See an example
snippet of code below involving T1, cur1 and T2, cur2. I cannot create
"cur2" as the complier will not create the underlying SQL cursor as
there is no "sql_cursor" that takes 4 arguments of transaction, adopted
cursor name, update policy and ownership policy. Instead the SQL cursor
expects 3 arguments - transaction, cursor name and ownership policy.
Please see the details below via an example , the flagged compiler error
and the constructor definitions for this problem.
As i am new to libpqxx, is there something stupid that I'm doing?
Thanks,
Don
Example showing problem with adopting stateless cursor
============================================
work T1(cnx, "stateless cursor");
string query = "select relname from pg_class;";
const string cursorRefName = "loose cursor";
stateless_cursor<cursor_base::read_only, cursor_base::loose>
cur1(T1, query, cursorRefName, true);
work T2(cnx, "stateless adaptor cursor");
stateless_cursor<cursor_base::read_only, cursor_base::loose>
cur2(T2, cursorRefName);
cur1.close();
Compiler errors with adopting stateless cursor
====================================
/usr/include/pqxx/cursor.hxx: In constructor 'pqxx::stateless_cursor<up,
op>::stateless_cursor(pqxx::transaction_base&, std::string) [with
pqxx::cursor_base::updatepolicy up = read_only,
pqxx::cursor_base::ownershippolicy op = loose]':
testFdrsTransactors.cc:931: instantiated from here
/usr/include/pqxx/cursor.hxx:310: error: no matching function for call
to 'pqxx::internal::sql_cursor::sql_cursor(pqxx::transaction_base&,
const std::string&, pqxx::cursor_base::updatepolicy,
pqxx::cursor_base::ownershippolicy)'
/usr/include/pqxx/cursor.hxx:207: note: candidates are:
pqxx::internal::sql_cursor::sql_cursor(pqxx::transaction_base&, const
std::string&, pqxx::cursor_base::ownershippolicy)
/usr/include/pqxx/cursor.hxx:203: note:
pqxx::internal::sql_cursor::sql_cursor(pqxx::transaction_base&, const
std::string&, const std::string&, pqxx::cursor_base::accesspolicy,
pqxx::cursor_base::updatepolicy, pqxx::cursor_base::ownershippolicy,
bool)
/usr/include/pqxx/cursor.hxx:195: note:
pqxx::internal::sql_cursor::sql_cursor(const
pqxx::internal::sql_cursor&)
make: *** [testFdrsTransactors.o] EtD
Header code defining stateless_cursor and sql_cursor
=========================================
/// Adopt existing scrolling SQL cursor.
stateless_cursor(
transaction_base &trans,
const PGSTD::string adopted_cursor) :
m_cur(trans, adopted_cursor, up, op)
{
// Put cursor in known position
m_cur.move(cursor_base::backward_all());
}
sql_cursor(transaction_base &t,
const PGSTD::string &cname,
cursor_base::ownershippolicy op);
************************************************
The information contained in, or attached to, this e-mail, may contain confidential information and is intended solely for the use of the individual or entity to whom they are addressed and may be subject to legal privilege. If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager. Please do not copy it for any purpose, or disclose its contents to any other person. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email.
************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pgfoundry.org/pipermail/libpqxx-general/attachments/20090721/0e741ef5/attachment.html>
More information about the Libpqxx-general
mailing list