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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts JES2 JEC: Use UNIX Pipes to Pass Data... Virendra Shambharkar JCL & VSAM 21 Tue Dec 20, 2016 6:55 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


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