Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Quote:
It can be anything. I just gave an example with 'AND'. Does it make any difference ?
Yes it might make a difference in your results. 'AND' does not make much sense in the context you showed. As far as building your sql dynamically, as Nic pointed out, you could choose any programming language of convenience, I'm sure there would be working examples in this forum. Post here if you come across any issues and someone would be around to help you. Good luck.
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OUTFIL IFTHEN=(WHEN=(1,3,CH,EQ,JP1),
BUILD=(C'SELECT * FROM TABLE',/,C'WHERE TABLE_FIELD=',JP2,/,
C' AND TABLE_FIELD=',JP3)),
IFTHEN=(WHEN=(1,3,CH,EQ,JP2),
BUILD=(C'SELECT * FROM TABLE',/,C'WHERE TABLE_FIELD=',JP1,/,
C' AND TABLE_FIELD=',JP3)),
IFTHEN=(WHEN=(1,3,CH,EQ,JP3),
BUILD=(C'SELECT * FROM TABLE',/,C'WHERE TABLE_FIELD=',JP1,/,
C' AND TABLE_FIELD=',JP2))
OPTION COPY
/*
SORTIN is having a blank line so that we can compare it with JPn values. I assumed all input fields have 3 byte length.
You can manipulate this logic according to your requirement.