Is it possible, with DB2/400 SQL, to select a specifc row by using its
relative record number,
for instance in oracle SQL I can go:
select * from file where rownum = 10, will return the 10th row in the
table
Thanks for your help.
Tama McConnell
Did you know that all IBM manuals are online at
http://as400bks.rochester.ibm.com ?
The DB2/400 SQL manual explains how to use RRN().
In your case SELECT * FROM table WHERE RRN(table) = 10
Regards,
Paul
-----------------------------
tama mcconnell wrote in message <01bf3ab4$77ba8520$53cfab92@TC030116>...
Hello,
Is it possible, with DB2/400 SQL, to select a specifc row by using its
relative record number,
for instance in oracle SQL I can go:
select * from file where rownum = 10, will return the 10th row in the
table
Thanks for your help.
Tama McConnell
The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, Merck & Co., Inc. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.
Hi, this's an example for retrive the 10th row in the table... in DB2/400
SQL
D sql_num C Const(2)
*
D MyStruct DS OCCURS(10)
D fld0001 15A
D fld0002 30A
*
D MyArray DS OCCURS(10)
D InfDs 4B 0 Dim(2)
*
C/EXEC SQL INCLUDE SQLDA
C/END-EXEC
*
C Eval sqld = 2
C Eval sqln = 2
C Eval sqldabc = 136
*
C Eval sqltype = 453
C Eval sqllen = 15
C Eval sql_var(1) = sqlvar
*
C Eval sqltype = 453
C Eval sqllen = 30
C Eval sql_var(2) = sqlvar
*
*...Dichiaro cursore per selezione.
C/EXEC SQL
C+ DECLARE C1 CURSOR FOR SELECT myFld01, myFld02 FROM MyLibl/MyFiles
C/END-EXEC
*
*...Apertura cursore.
C/EXEC SQL OPEN C1
C/END-EXEC
*
*...se ci sono errori FINE.
C/EXEC SQL WHENEVER SQLERROR GOTO ERRORE
C/END-EXEC
*
C/EXEC SQL
C+ FETCH C1 FOR 10 ROWS USING DESCRIPTOR :SQLDA INTO :myStruct:myArray
C/END-EXEC
*
C Do SQLERRD(3) Inx 6 0
C Inx Occur myStruct
C...
C EndDo
*
C ERRORE TAG
*
C Eval *InLR = *On
tama mcconnell <tama.mc...@telecom.co.nz> wrote in message
news:01bf3ab4$77ba8520$53cfab92@TC030116...
Select RRN(myfile) from myfile where "condition"
This will return all the the row numbers from myfile that meet the "where"
condition
Tama
Paul Nicolay <removethis....@merck.com> wrote in article
<8201dj$a41$1...@merck.com>...
Given the way you worded your question, yes, it is possible by using the
RRN() function. But keep in mind that this function does in fact return
a physical relative record number, not a row number. When records are
deleted, the record numbers of the remaining records do not change
unless the file is reorganized. Also, an ORDER BY does not affect RRN();
the first physical record still returns RRN()=1 no matter what row it is
in the result table.
Tom Liotta
In article <01bf3ab4$77ba8520$53cfab92@TC030116>,
"tama mcconnell" <tama.mc...@telecom.co.nz> wrote:
> Hello,
>
> Is it possible, with DB2/400 SQL, to select a specifc row by using
its
> relative record number,
> for instance in oracle SQL I can go:
>
> select * from file where rownum = 10, will return the 10th row in the
> table
>
> Thanks for your help.
>
> Tama McConnell
>
--
Tom Liotta
AS/400 systems programmer
Sent via Deja.com http://www.deja.com/
Before you buy.