Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
DB2 Select to retrieve the current day transactions

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

New User


Joined: 19 Dec 2004
Posts: 24
Location: hyderabad

PostPosted: Wed Nov 07, 2007 11:10 pm    Post subject: DB2 Select to retrieve the current day transactions
Reply with quote

Hi,

Can any one tell me the select statement in DB2,to retrieve the current day transactions from one table.

My table have one field Transaction_Date, which contains Timestamp value.

so i want select the current date transactions daily from that table using that Transaction_date field.

This job i want to run daily,because of that i am not hardcoding the date in where clause.

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

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Thu Nov 08, 2007 12:12 am    Post subject:
Reply with quote

If the job is to run daily, and extract transactions for yesterday or today, do a SET :WS-TIMESTAMP = current_timestamp - 1 days (if for yesterday). or without the - 1 days if only for today. be careful if you are trying to extract fridays work on monday.

anyway, move ws-timestamp after the SET to ws-ts-upper-range and ws-ts-lower-range. modifiy the hours, min, sec, millisecs in lower to zeros and the upper range to 23 59 59 99999. use the upper and lower ranges in a where clause column_ts between upper and lower.

you might think about having a place to store the last timestamp used for extraction. then manipulate that with sql + 1 days for your current daily extraction needs. That would enable you to extract on fri, save the low-range timestamp (because it is already set to zeroes). use sql to add 1 day and generate your high range based on today. that way you can extract saturday, sun and mon on monday.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Thu Nov 08, 2007 1:00 am    Post subject: Re: DB2 Select
Reply with quote

venkatarao wrote:
Hi,

Can any one tell me the select statement in DB2,to retrieve the current day transactions from one table.

My table have one field Transaction_Date, which contains Timestamp value.

so i want select the current date transactions daily from that table using that Transaction_date field.

This job i want to run daily,because of that i am not hardcoding the date in where clause.

Thanks,
venkat

Code:
SELECT * FROM TABLE WHERE DATE(TRANSACTION_DATE) = CURRENT DATE


Why does a column called TRANSACTION_DATE contain a timestamp?
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 Comparing 2 Files using Current time arunsoods SYNCSORT 9 Fri Sep 22, 2017 6:00 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us