Can you please tell us how set this prefetch attribute in followinglines. - Mailing list pgsql-general

From M Tarkeshwar Rao
Subject Can you please tell us how set this prefetch attribute in followinglines.
Date
Msg-id VI1PR0701MB271869EC2BEDD69E1D0CEC86AE6D0@VI1PR0701MB2718.eurprd07.prod.outlook.com
Whole thread Raw
Responses Re: Can you please tell us how set this prefetch attribute infollowing lines.
Re: Can you please tell us how set this prefetch attribute infollowing lines.
Can you please tell us how set this prefetch attribute in followinglines.
List pgsql-general

Hi all,

 

How to fetch certain number of tuples from a postgres table.

 

Same I am doing in oracle using following lines by setting prefetch attribute.

 

For oracle

// Prepare query
    if( OCIStmtPrepare( myOciStatement, myOciError, (text *)aSqlStatement,

// Get statement type
 OCIAttrGet( (void *)myOciStatement, OCI_HTYPE_STMT, &statement_type, 0, OCI_ATTR_STMT_TYPE, myOciError );

// Set prefetch count       

  OCIAttrSet( myOciStatement, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, myOciError );   

// Execute query
status = OCIStmtExecute( myOciServerCtx, myOciStatement, myOciError, iters, 0, NULL, NULL, OCI_DEFAULT );

 

 

For Postgres

 

Can you please tell us how set this prefetch attribute in following lines. Is PQexec returns all the rows from the table?

 

mySqlResultsPG = PQexec(connection, aSqlStatement);

if((PQresultStatus(mySqlResultsPG) == PGRES_FATAL_ERROR ) || (PQstatus(connection) != CONNECTION_OK)){}
if ((PQresultStatus(mySqlResultsPG) == PGRES_COMMAND_OK) || (PQresultStatus(mySqlResultsPG) == PGRES_TUPLES_OK))
    {
        myNumColumns = PQnfields(mySqlResultsPG);
        myTotalNumberOfRowsInQueryResult = PQntuples(mySqlResultsPG);
        myCurrentRowNum = 0 ;
    }

 

Regards

Tarkeshwar

 

pgsql-general by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: PostgreSQL memory usage
Next
From: Laurenz Albe
Date:
Subject: Re: A little confusion about JSON Path