IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Set the number of rows Using Utility


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon Nov 21, 2011 10:08 am
Reply with quote

Hi ,

I am Using a DB2 Utility to extract the table to a flat file.

Code:
UNLOAD                                                     
TABLESPACE DMSD0020.DMST0090                               
         UNLDDN U001                                       
         SHRLEVEL CHANGE                                   
         FROM TABLE DBA.DMSTBUSINESS_NAME                 
         (DUNS_NBR                       INTEGER           
         ,BUS_NME                        CHAR(30)         
         ,DT_LAST_UPD                    DATE EXTERNAL     
         ,BUS_NME_CMPLT                  CHAR(90)         
         ,BUS_NME_INVRD                  CHAR(30)         
         ,BUS_NME_REV_DT                 DATE EXTERNAL     
         ,BUS_NME_USG_CD                 CHAR(1))         


Using this , i get the whole table being extract.

My requirement is, I need to fetch only the first 1000 rows of the above table. Can you please help in this.
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Mon Nov 21, 2011 11:24 am
Reply with quote

You can use the limit parameter

LIMIT integer Specifies the maximum number of rows that are to be
unloaded from a table. If the number of unloaded rows
reaches the specified limit, message DSNU1201 is issued for
the table, and no more rows are unloaded from the table.
The process continues to unload qualified rows from the
other tables.

When partition parallelism is activated, the LIMIT option
is applied to each partition instead of to the entire
table.

integer
Indicates the maximum number of rows that are to be
unloaded from a table. If the specified number is less
than or equal to zero, no row is unloaded from the
table.

Like the SAMPLE option, if multiple tables are unloaded
with the LIMIT option, the referential integrity between
the tables might be lost.
Back to top
View user's profile Send private message
chockalingam_rsp

New User


Joined: 13 Aug 2009
Posts: 43
Location: chennai

PostPosted: Mon Nov 21, 2011 11:27 am
Reply with quote

could you please give me the syntax , coz when i tried this option it gave me error stating that "KEYWORD 'LIMIT' INCOMPATIBLE WITH OTHER KEYWORDS OR OPERANDS "

I gave it as following

Code:
        ,BUS_NME_REV_DT                 DATE EXTERNAL   
        ,BUS_NME_USG_CD                 CHAR(1))       
        LIMIT 1000
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Nov 21, 2011 1:12 pm
Reply with quote

Quote:
I need to fetch only the first 1000 rows of the above table
Without an "ORDER BY", "first nnnn" does not make much sense from DB2 per se . If you use an ORDER BY in the SQL query you'll fetch the first 1000 of the result-set. Having said that, please check if Fetching a limited number of rows: FETCH FIRST n ROWS ONLY works for you.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Nov 21, 2011 1:30 pm
Reply with quote

chockalingam_rsp,

Why do prefer to do it using UNLOAD rather using DSNTIAUL?
Is that because of client requirement or something?? Curious to know.
Back to top
View user's profile Send private message
db2sysdba.zos

New User


Joined: 04 Oct 2011
Posts: 25
Location: INDIA

PostPosted: Mon Nov 21, 2011 1:55 pm
Reply with quote

Hi chockalingam_rsp,

Code:
UNLOAD                                                     
TABLESPACE DMSD0020.DMST0090                               
         UNLDDN U001                                       
         SHRLEVEL CHANGE                                   
         FROM TABLE DBA.DMSTBUSINESS_NAME  LIMIT integer       
         (DUNS_NBR                       INTEGER           
         ,BUS_NME                        CHAR(30)         
         ,DT_LAST_UPD                    DATE EXTERNAL     
         ,BUS_NME_CMPLT                  CHAR(90)         
         ,BUS_NME_INVRD                  CHAR(30)         
         ,BUS_NME_REV_DT                 DATE EXTERNAL     
         ,BUS_NME_USG_CD                 CHAR(1))


Try this syntax....
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Nov 21, 2011 2:27 pm
Reply with quote

did anybody notice that Your posts were edited to add the code tags
in order to make easier for people willing to help to read and understand the posted code icon_question.gif
do it Yourself when You post not to waste the moderators time to do it on Your behalf icon_evil.gif

code tags and preview will keep everybody happy icon_cool.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
No new posts REASON 00D70014 in load utility DB2 6
Search our Forums:

Back to Top