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

can UNLOAD utility use the WHERE clause??


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

New User


Joined: 17 Nov 2006
Posts: 6

PostPosted: Wed Jun 06, 2007 11:20 pm
Reply with quote

Hi,

I have a table which has to be unloaded, only those rows which are not older than 180 days from current date.

Ex:
select * from abcd.xyx_pqr where sct_evt_dt + 180 days
> current_date

the difficulty here is that i am not supposed to use IKJEFT1A utility but have to use DSNUTILB pgm to download the data.

So wanted to know if there is any possibility of
unloading selected rows which match the query above.

Though i have tried the WHEN clause , it doesn't allow any arithmetic operators.

Regards,
Sana.

P.S: No SQL select statement has to be used.
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 459
Location: Belgium

PostPosted: Thu Jun 07, 2007 12:02 am
Reply with quote

maybe something like
Code:
UNLOAD TABLESPACE abcd.xyx_pqr
 FROM TABLE abcd.xyx_pqr
 HEADER NONE
 WHEN ( sct_evt_dt + 180 days )
 SHRLEVEL CHANGE   


Not tested for arithmetic operation. Have a try.
Back to top
View user's profile Send private message
wanderer

Active User


Joined: 05 Feb 2007
Posts: 199
Location: Sri Lanka

PostPosted: Thu Jun 07, 2007 2:26 am
Reply with quote

According to the manual, it is possible. If it doesn't work, you may post your complete UNLOAD statement and somebody will suggest something here.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


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

PostPosted: Thu Jun 07, 2007 8:24 am
Reply with quote

See unload is nothing but bulk select.Normally when you run a spufi you have some limits to that you cant fetch all the ROWS for your query.That is why we opt for running a spufi in batch.Just like your normal unload give the datasets sysrec and syspunch.In SYSIN you can give your statement
like

Code:


select empid,emdno,salary from employee where salary>6000;



This will work as the same unload.
Hope this helps.

Thanks,
Prem
Back to top
View user's profile Send private message
peeterparker

New User


Joined: 17 Nov 2006
Posts: 6

PostPosted: Thu Jun 07, 2007 12:21 pm
Reply with quote

UNLOAD DATA PUNCHDDN SYSPUNCH UNLDNN SYSRECCOO
FROM TABLE ABC.PR_XYZ
WHEN ( STRT_DT + 2 DAYS > CURRENT_DATE )

The error is

INVALID KEYWORD - + in the WHEN line.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


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

PostPosted: Thu Jun 07, 2007 1:57 pm
Reply with quote

can you please copy paste your code becasue I find your code to contain
some errors.
Please use the coding conventions used in this forum and then paste your code.


Thanks,
Prem
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Thu Jun 07, 2007 6:17 pm
Reply with quote

The UNLOAD WHEN clause allows "between" as well as >, >=, <, <=.

Can you use several compares with AND or OR?

The compare can be with a labeled-duration-expression, which includes the various date and timestamp components. See UNLOAD syntax documentation for the details.

Does this help?
Back to top
View user's profile Send private message
wanderer

Active User


Joined: 05 Feb 2007
Posts: 199
Location: Sri Lanka

PostPosted: Fri Jun 08, 2007 6:59 am
Reply with quote

This should work,

Code:
UNLOAD DATA PUNCHDDN SYSPUNCH UNLDNN SYSRECCOO
FROM TABLE ABC.PR_XYZ
WHEN ( STRT_DT > (CURRENT_DATE - 2 DAYS) )
Back to top
View user's profile Send private message
peeterparker

New User


Joined: 17 Nov 2006
Posts: 6

PostPosted: Sun Jun 10, 2007 8:37 pm
Reply with quote

Code:
UNLOAD DATA PUNCHDDN SYSPUNCH UNLDNN SYSRECCOO
FROM TABLE ABC.PR_XYZ
WHEN ( STRT_DT > (CURRENT_DATE - 2 DAYS) )



thnax a zillion!!!
Back to top
View user's profile Send private message
wanderer

Active User


Joined: 05 Feb 2007
Posts: 199
Location: Sri Lanka

PostPosted: Mon Jun 11, 2007 12:55 pm
Reply with quote

You are welcome! icon_smile.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 Load new table with Old unload - DB2 DB2 6
No new posts Remote Unload of CLOB Columns DB2 6
No new posts Multiple table unload using INZUTILB DB2 2
No new posts REASON 00D70014 in load utility DB2 6
No new posts changing defaults in db2 admin - Unlo... DB2 0
Search our Forums:

Back to Top