Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > PQexecPrepared ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 9273 of 9628
Post > Topic >>

PQexecPrepared with cursor to fetch single results

by Maurizio Oristanio <maurizio.oristanio@[EMAIL PROTECTED] > Apr 28, 2008 at 05:21 AM

if you need a scrollable cursor for a prepared statement (to fetch
single rows from huge result sets)
while still being able to execute statements on the same connection
you can do it this way:

PGresult* res = PQprepare( con, "statement1", "declare cu1 scroll
cursor with hold for select * from table where col1=$1", 0, NULL );
PGresult* res2 = PQdescribePrepared( con, "statement1" );
//now use PQnparams and PQnparamtype to determine parameter
information
//and set paramCount, paramValues and paramLength accordingly
PGresult* res3 = PQexecPrepared( con, "statement1", paramCount,
paramValues, paramLength, paramFormat, 0 );
PGresult* res4 = PQexec( con, "fetch forward 100 from cu1" ); //to
receive 100 rows from the server
//now with PQnfields, PQftype and PQfname and PQgetvalue access the
result - and other queries can be executed on the same connection




 1 Posts in Topic:
PQexecPrepared with cursor to fetch single results
Maurizio Oristanio <ma  2008-04-28 05:21:49 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Fri Jul 4 9:20:40 CDT 2008.