|
Re: pro*c when fetch out of sequence will come [message #94526 is a reply to message #94524] |
Wed, 05 January 2005 00:44 |
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
|
|
|