View previous topic :: View next topic
|
Author |
Message |
chockalingam_rsp
New User
Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
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 |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
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 |
|
|
chockalingam_rsp
New User
Joined: 13 Aug 2009 Posts: 43 Location: chennai
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
db2sysdba.zos
New User
Joined: 04 Oct 2011 Posts: 25 Location: INDIA
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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
do it Yourself when You post not to waste the moderators time to do it on Your behalf
code tags and preview will keep everybody happy |
|
Back to top |
|
|
|