Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> get NumResultCols, any better way?

get NumResultCols, any better way?

From: James Chen <james_at_iweave.com>
Date: 1997/03/14
Message-ID: <3329B4EA.99E@iweave.com>#1/1

Hi Oracle/OCI gurus,

What's the best way to know NumResultCols of a query in OCI ?

One naive way is to use the following sequential loop:

  BOOL bError = FALSE;
  int nNumResultCols = 0;

  for (int pos = 1; pos < MAX_NUMBER_OF_ITEMS; pos++) {     rc = odescr(&cda, pos, ...);
    if (rc == 1007) break;
    if (rc < 0) {

      // handle error
      bError = TRUE;
      break;

    }
}

  if (!bError) {
    nNumResultCols = pos - 1;
}

The drawback of the above loop is the inefficiency. odescr() OCI call goes to the server every time you call it. If there are large # of columns in a query, it would be really inefficient.

One way I can think of to improve the efficiency is to call odescr() with a 'pos' picked in binary-searching fashion.   

Is there a better way to do it ?

-- 
james_at_iweave.com

James Chen,	at Interweave Software, Inc.
Received on Fri Mar 14 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US