Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: ROWNUM is driving me nuts - queries suggested produced no res
> just what is it you want to return in your query?
If the query results are to be displayed a chunk at a time on a web page
then you should give strong consideration to using OCI and implementing
scrollable cursors with the OCIStmtFetch2() function and its
OCI_FETCH_NEXT, OCI_FETCH_PRIOR, OCI_FETCH_FIRST, OCI_FETCH_LAST,
OCI_FETCH_ABSOLUTE orientation parameters and nrows parameter. This is
Oracle9i only. With Oracle8i you can use OCI_FETCH_NEXT with nrows but
you can't go backwards. Oracle recommends migrating all OCIStmtFetch()
calls to OCIStmtFetch2() calls.
Steve Orr
Bozeman, Montana
-----Original Message-----
Sent: Wednesday, July 09, 2003 10:35 AM
To: Multiple recipients of list ORACLE-L
res
MaryAnn,
the best way to understand rownum is to do the following:
SQL> SELECT ROWNUM, GENDER
2 FROM (SELECT ROWNUM, GENDER
3 FROM EMP2 4 WHERE ROWNUM <= 20)
You will quickly see that, no matter how you order the result set, the first record returned is rownum #1, second is rownum #2 etc. The rownum value is assigned as rows are RETURNED or DISPLAYED, not as they are selected.
when you run your original query:
SQL> SELECT ROWNUM, GENDER
2 FROM (SELECT ROWNUM, GENDER
3 FROM EMP2 4 WHERE ROWNUM <= 20)
just what is it you want to return in your query?
Tom Mercadante
Oracle Certified Professional
-----Original Message-----
Sent: Wednesday, July 09, 2003 12:19 PM
To: Multiple recipients of list ORACLE-L
results
I definitely dont fully understand ROWNUM yet, and you guys so far provided more info than a couple of books by Oracle, that I have here. For a second I thought I'm beginning to get it, but the queries suggested produced no results...
SQL> SELECT ROWNUM, GENDER
2 FROM (SELECT ROWNUM, GENDER
3 FROM EMP2 4 WHERE ROWNUM <= 20)
SQL> SELECT r, GENDER
2 FROM (SELECT ROWNUM r, GENDER
3 FROM EMP2 4 WHERE ROWNUM <= 20)
SQL> SELECT r "ROWNUM", GENDER
2 FROM (SELECT ROWNUM r, GENDER
3 FROM EMP2 4 WHERE ROWNUM <= 20)
SQL> ... so, any help is appreciated - rownum is driving me nuts...
thx
maa
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services ---------------------------------------------------------------------To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Wed Jul 09 2003 - 12:15:59 CDT
![]() |
![]() |