IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Pass variable to Query.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Sun May 23, 2010 11:47 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts RC query -Time column CA Products 3
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top