Page 1 of 1

Need to pass DATE To DB2 query

PostPosted: Fri Dec 28, 2012 10:27 am
by Ketaki
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?

Re: Need to pass DATE To DB2 query

PostPosted: Fri Dec 28, 2012 8:34 pm
by dick scherrer
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?

Re: Need to pass DATE To DB2 query

PostPosted: Fri Dec 28, 2012 8:46 pm
by enrico-sorichetti
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 )

Re: Need to pass DATE To DB2 query

PostPosted: Tue Jan 08, 2013 6:39 am
by tivrfoa
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.

Re: Need to pass DATE To DB2 query

PostPosted: Tue Jan 08, 2013 4:57 pm
by tivrfoa
Link to competitor site removed

Re: Need to pass DATE To DB2 query

PostPosted: Tue Jan 08, 2013 5:17 pm
by BillyBoyo
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.

Re: Need to pass DATE To DB2 query

PostPosted: Tue Jan 08, 2013 5:22 pm
by tivrfoa
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