View previous topic :: View next topic
|
Author |
Message |
webxpertin Warnings : 1 New User
Joined: 05 Apr 2005 Posts: 9 Location: india
|
|
|
|
How to get the 5th record from a DB2 table or a 100th record from a vsam file directly without knowing any key of that particular record?
Thanks |
|
Back to top |
|
|
Abirami.YN
New User
Joined: 16 Jul 2005 Posts: 15 Location: India - Chennai
|
|
|
|
Hi,
Try the following in DB2
SELECT *
FROM (SELECT
ROW_NUMBER() OVER (ORDER BY empno ASC) AS rownumber,
empno, firstnme
FROM edwarde.employee
) AS foo
WHERE rownumber = 5;
After executing this query , tell me ur result (I am not sure) |
|
Back to top |
|
|
shobam
New User
Joined: 18 Jul 2005 Posts: 34 Location: CN
|
|
Back to top |
|
|
Gops
New User
Joined: 21 Jul 2005 Posts: 23
|
|
|
|
Hi Guys,
Tried with both of your examples,
but I am getting a syntax error on the over clause of the query.
Cheers,
Gopal |
|
Back to top |
|
|
vasudev9
New User
Joined: 02 Aug 2005 Posts: 1 Location: india
|
|
|
|
How to get the 5th record from a DB2 table or a 100th record from a vsam file directly without knowing any key of that particular record?
Hi
To get 100th record from a vsam file, try this in IDCAMS
REPRO -
INFILE(DD1) -
OUTFILE(DD2) -
SKIP(99) -
COUNT(1)
This example SKIPS 99 Records and copies next 1 record.
Hope this do..
vasudev |
|
Back to top |
|
|
withnams
New User
Joined: 06 Jul 2005 Posts: 26 Location: Chennai
|
|
|
|
It depends upon the version of the DB2 you are using? |
|
Back to top |
|
|
vijayamadhuri
Active User
Joined: 06 Apr 2005 Posts: 180
|
|
|
|
to obtain the 5 th record use the following
EXEC SQL FETCH ABSOLUTE +5 C1 INTO :HVDEPTNO, :DEPTNAME, :MGRNO;
To fetch the fifth row from the end of the result table, use this FETCH statement:
EXEC SQL FETCH ABSOLUTE -5 C1 INTO :HVDEPTNO, :DEPTNAME, :MGRNO;
In this way u can fetch any row u require |
|
Back to top |
|
|
|