Re: Numer of rows in a cursor
Posted in 1997
Topics: Error Codes & Troubleshooting
greggd09@aol.com (GreggD09) wrote: >I don't know about 7 but >I know that in Informix Online 5.0 SQLCA.SQLERRD[3] contains the number >of >records selected Update insert etc. I think it can be used after all rows are fetched. I'm using in my browser the next: Big TSqlQueryDoc::ReCountAll() { ${ $char* cu; $char* ds; $long int p; unsigned long int gap; double lp; cu = Cursor; ds = Descriptor; lp = (double) 0xffffffff+1; // p = lp-1; lenne jo de nem nyesi at fordul mert elojeles ?!?!? // a max olvasasa beolvassa mindet ez a leg lassabb es biztos(?) hogy SQLNOTFOUND-ot ad vissza p = lp/2 - 1; try{ SetSqlEvent(true); BeginConnection(); $FETCH ABSOLUTE $p $cu USING SQL DESCRIPTOR $ds; EndConnection(TSqlConnection::Check, SQLNOTFOUND); SetSqlEvent(false); } catch(...){ SetSqlEvent(false); throw; } p = gap = lp/2; SetHook(Async1); // egy darabig kikapcsoljuk, most lehet mert a tobbi gyorsabb lesz for(int i = 1; i <= 32; i++){ BeginConnection(); $FETCH ABSOLUTE $p $cu USING SQL DESCRIPTOR $ds; EndConnection(TSqlConnection::Check, SQLNOTFOUND); lp = (unsigned long int) p; if(SQLCODE){ // nincs ennyi if(gap != 1){ gap /= 2; p -= gap; } } else{ // tobb van p++; BeginConnection(); $FETCH ABSOLUTE $p $cu USING SQL DESCRIPTOR $ds; EndConnection(TSqlConnection::Check, SQLNOTFOUND); p--; if(SQLCODE){ // nincs tobb break; // az utolso } gap /= 2; p = (unsigned long int) p + gap; } } if( p == 1){ BeginConnection(); $FETCH ABSOLUTE $p $cu USING SQL DESCRIPTOR $ds; if( EndConnection(TSqlConnection::Check, SQLNOTFOUND) ) // egy sincs p = 0; // } RealRecNo = p; SetHook(Async0); return RealRecNo; $} } Advantage: After the first FETCH all of the rows are in the temp table of the SCROLL cursor ,you can seek anywhere relatively quick later Disadvantage: came from that, because FETCHing all the rows is using a lot of resources and could take a long time. Good luck Hofi -------------------==== Posted via Deja News ====----------------------- http://www.dejanews.com/ Search, Read, Post to Usenet