Having requirement to fetch record number 500 to 1000 from a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kunwarmanish
    New Member
    • Jun 2010
    • 1

    #1

    Having requirement to fetch record number 500 to 1000 from a table

    Hi,
    I have environment for DB2 v8 in z/OS and created one table by using:
    Code:
    CREATE TABLE QUERY_ANALYSIS (
       name varchar(50),
       destination varchar(50),
       description varchar(50),
       nine_code varchar(50) ,
       points varchar(50),
       team varchar(50),
       group1 varchar(50),
       office varchar(50) ,
       is_present INTEGER,
       p_nine_code varchar(50) 
       )
    having no primary key.
    and inserted about 10k records, now i want to fetch only record number 500 to 100.
    What could be the option to get it using SPUFI?

    Actually I am not a DB2 guy but my tool developed in JAVA is having requirement to scan DB2 database and fetch records in batch of records without knowing the database description like unique id, pk and all, so there should be some option like we have in mysql:
    Code:
    select * from some_table limit 500,1000;
    Last edited by MMcCarthy; Jun 16 '10, 10:07 PM. Reason: Added code tags - see # icon on posting window
  • kleach
    New Member
    • Jun 2010
    • 15

    #2
    If you need record number access in db2, you should use an "identity" column in the table ddl. This will generate a rownum for each row for you.

    Without this in place, you can try using "fetch first 1000" on your select to sample the data in the table, the throw out the first 499 with some other tool.

    Coolness has been added in the most recent UDB where you can set Oracle compatability as in
    Code:
      db2set DB2_COMPATIBILITY_VECTOR=ORA
    Then
    Code:
    SELECT * FROM table
         WHERE ROWNUM BETWEEN 20 AND 40;
    works as expectd.

    Good luck.

    Comment

    Working...