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
 

 

Pass variable to Query.

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

New User


Joined: 31 Aug 2005
Posts: 82

PostPosted: Sun May 23, 2010 11:28 am    Post subject: Pass variable to Query.
Reply with quote

Hi,

Is there any way to pass variable to a query during batch job?

SET TRANDATE=39090
SET ACCTNO=%%%%%%0019110001

Then I have an SQL select statement for my extract that uses the variables above.

//SYSIN DD *
SELECT ACCT_NO,TRAN_DATE,JRNL_NO,TRAN_TYPE,VAR_AREA
FROM U1BANCS.GECT WHERE
INST_NO = '003' AND
ACCT_NO LIKE ACCTNO AND
TRAN_DATE = TRANDATE AND
(TRAN_TYPE = 1 OR TRAN_TYPE = 20)
ORDER BY INST_NO ASC,
ACCT_NO ASC ,
TRAN_TYPE ASC,
TRAN_DATE DESC,
REC_NO ASC
;

But when I run the job, I get an error. Is there a way to use the variables declared in the job?

Thanks & Regards,
Manshadi
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun May 23, 2010 11:47 am    Post subject:
Reply with quote

Hello,

No, you cannot do this the way you are trying.

You could have a bit of code that would use the variables as PARM fields and generate the proper sql statements writing them into a file.

Then you could use concatenation to collect the first constant bit of sql, the generated acct_no/tran_date predicates, and the last bit of constant sql.
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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