Need to pass DATE To DB2 query



IBM's flagship relational database management system

Need to pass DATE To DB2 query

Postby Ketaki » Fri Dec 28, 2012 10:27 am

Hi,

I have a COBOL-DB2 program which is reading a file containing date. Lets say TODATE.
TODATE is moved to SQLDATE

MOVE TODATE TO SQLDATE.


One of the query from program is like

INSERT INTO TMP_ADJ
SELECT                           
     A.COMPANY                   
    ,A.PRODUCT                   
    ,A.ACTIVFROM                 
    ,SUM(A.AMOUNT               
        )  AS                   
           AMOUNT               
FROM         BILDET A       
WHERE A.COMPANY   = 1           
  AND A.ATRNTYPE  IN('MN','TI','PO')         
  AND A.ACTIVFROM > :SQL-TODATE 
  AND A.TRANDATE <= :SQL-TODATE 
GROUP BY                         
     A.COMPANY                   
    ,A.PRODUCT                   
    ,A.ACTIVFROM   



Now,

For some reasons, I need to remove this query from program. And will be executed seperately through JCL.

Is there anyway to pass this SQLDATE (i.e. TODATE) to this SQL query, rather than hardcoding it?
Ketaki
 
Posts: 2
Joined: Fri Jun 01, 2012 12:04 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Need to pass DATE To DB2 query

 

Re: Need to pass DATE To DB2 query

Postby dick scherrer » Fri Dec 28, 2012 8:34 pm

Hello,

For some reasons, I need to remove this query from program. And will be executed seperately through JCL.
You might remove the query from the program, but it will not be executed "through JCL". . .

Why not use a similar bit of program code to run this "removed" query?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Need to pass DATE To DB2 query

Postby enrico-sorichetti » Fri Dec 28, 2012 8:46 pm

Why not use a similar bit of program code to run this "removed" query?


I posted a link to the IDUG with a couple of very interesting tools

db2/topic8619.html

the first one could be a good way to learn to write a generalized DB2 access module
customized to the user/organization needs

also DSNTEP2 source is available, but it is PL/I and it would be a bit more difficult to customize it
( lack of PL/I skills and/or the PL/I compiler )
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Need to pass DATE To DB2 query

Postby tivrfoa » Tue Jan 08, 2013 6:39 am

I think you can concatenate a query with a data set that contains the date.
http://ibmmainframes.com/about50539.html
I saw a post that has an example. I'll try to find it tomorrow.
tivrfoa
 
Posts: 83
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 58 times
Been thanked: 0 time

Re: Need to pass DATE To DB2 query

Postby tivrfoa » Tue Jan 08, 2013 4:57 pm

Link to competitor site removed
tivrfoa
 
Posts: 83
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 58 times
Been thanked: 0 time

Re: Need to pass DATE To DB2 query

Postby BillyBoyo » Tue Jan 08, 2013 5:17 pm

tivrfoa, please don't post links to competitor sites. If the site you want to link to has advertising on it, don't post the link. Suggest google instead.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Need to pass DATE To DB2 query

Postby tivrfoa » Tue Jan 08, 2013 5:22 pm

BillyBoyo wrote:tivrfoa, please don't post links to competitor sites. If the site you want to link to has advertising on it, don't post the link. Suggest google instead.

Ok. Sorry.

Google:
how to run dynamic sql through ikjeft01 utility
tivrfoa
 
Posts: 83
Joined: Wed Aug 22, 2012 6:35 pm
Has thanked: 58 times
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post