Home » Developer & Programmer » Precompilers, OCI & OCCI » pro*c when fetch out of sequence will come
pro*c when fetch out of sequence will come [message #94524] Mon, 03 January 2005 23:35 Go to next message
bhanuprasad
Messages: 6
Registered: December 2004
Junior Member
how to detect fetch out of sequence & how to solve fetch out of sequence with example
Re: pro*c when fetch out of sequence will come [message #94526 is a reply to message #94524] Wed, 05 January 2005 00:44 Go to previous message
Michael Hartley
Messages: 110
Registered: December 2004
Location: West Yorkshire, United Ki...
Senior Member

if you have to fetch 101 record and your array size is 10, then you will need 10 fetches of 10 records and 1 fetch of 1 record, when you have made a fetch that does not fill the array, you know you have all the records. Or you can fetch repeated until sqlca.sqlcode>0.

use sqlca.sqlerrd[[2]] to see how many rows you have -- and "break" at the BOTTOM
of the loop

pro*c code is roughly like this:

EXEC SQL OPEN C;
for ( last_fetch_count = 0; ; last_fetch_count = sqlca.sqlerrd[[2]] )
{
EXEC SQL FOR :array_size FETCH C into ...;

printf( "Apparently fetched %d rows this fetch...n",
sqlca.sqlerrd[[2]]-last_fetch_count );


for( j = 0; j < sqlca.sqlerrd[[2]]-last_fetch_count; j++ )
{
process row j
}
/*
* when the sqlcode is positive, that indicates NO MORE DATA, break
*/
if ( sqlca.sqlcode > 0 ) break;
}
printf( "%d rowsn", row_count );


code example donated by Giridhar from India.

Michael Hartley
Openfield Solutions Ltd
www.openfieldsolutions.co.uk
Previous Topic: Oracle 9i OCI (Solaris vs AIX)
Next Topic: Connection from 8.1.6 pro*c to 9.2 database
Goto Forum:
  


Current Time: Thu Mar 28 17:19:43 CDT 2024