Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Unload based on year

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
itmanand

New User


Joined: 18 Dec 2008
Posts: 24
Location: Newyork

PostPosted: Thu Dec 25, 2008 3:07 am    Post subject: Unload based on year
Reply with quote

I have field in my table that is defined as SMALLINT. Below is the field, the format and the values.

AB_YEAR SMALLINT

The values 2001, 2002, 2003,2004, 2005, 2006, 2007 and 2008.

I want to run two unload queries.
1. To fetch the data prior to 2007 in file-1.
2. To fetch the data from 2007 into file-2.

I can do this by giving AB_YEAR < 2007 and AB_YEAR >= 2007. However I want this to be dynamic and do not want to change ti next year to AB_YEAR < 2008 and AB_YEAR >= 2008.

Can someone help me on this?
Back to top
View user's profile Send private message

Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2284
Location: @my desk

PostPosted: Thu Dec 25, 2008 11:49 am    Post subject:
Reply with quote

itmanand,

This might be of some help.

YOUR_TABLE
Code:
 AB_YEAR
SMALLINT
--------
********
    2001
    2002
    2003
    2004
    2005
    2006
    2007
    2008
SQL
Code:
SELECT AB_YEAR                             
FROM   YOUR_TABLE                 
WHERE  AB_YEAR < YEAR(CURRENT TIMESTAMP) - 1
WITH UR;

RESULT
Code:
 AB_YEAR
SMALLINT
--------
********
    2001
    2002
    2003
    2004
    2005
    2006
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2284
Location: @my desk

PostPosted: Thu Dec 25, 2008 11:53 am    Post subject:
Reply with quote

itmanand,

Just curious, does this have anything to do with an almost similar requirement in SyncSort posted by you HERE.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts unload data from table with lob columns farhad_evan DB2 1 Sat Apr 22, 2017 1:32 pm
This topic is locked: you cannot edit posts or make replies. Need help in estimating space of unlo... ashek15 IMS DB/DC 12 Fri Apr 07, 2017 5:11 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us