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

SQL WHERE clause should be based on the JCL Parm value


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Sivagurunathan Jagadeesan

New User


Joined: 06 Mar 2007
Posts: 32
Location: India

PostPosted: Tue May 22, 2007 9:24 pm
Reply with quote

Hi,

I am working on a code in which the WHERE clause should be based on the Parm value passed from the JCL,

Eg Declare ABCD Cursor for
Select A.Name,
B.Age
From XXXXX.XXXXX A,
YYYYY.YYYYY B
where A.Name = B.Name
and B.Age = B.Age
and A.Date > 01/01/1900

Now based on the Parm passed, I would like to include the second Where clause (B.Age = B.Age) or the third clause (A.Date > 01/01/1900).

I tried using CASE/ IF conditions but it didn?t work.

Any suggestions on this would be very helpful.

Thanks,
Siva
Back to top
View user's profile Send private message
radhakrishnan82

Active User


Joined: 31 Mar 2005
Posts: 435
Location: chennai, India

PostPosted: Tue May 22, 2007 9:35 pm
Reply with quote

rather than case/if on query, use same query more than once for the different parm values. Based on the parm, only one query will execute.

let me know whether this answers you.

Hope this helps

regds,
radhakrishnan
Back to top
View user's profile Send private message
Sivagurunathan Jagadeesan

New User


Joined: 06 Mar 2007
Posts: 32
Location: India

PostPosted: Wed May 23, 2007 7:26 am
Reply with quote

Hi,

Thanks a lot for your thoughts.

I did think of it, but it is the main cursor in the program, so declaring twice might be a problem. Other point is that it is a One time activity (for the first run only) for the successive runs we will not be need this logic in "Where" clause.

I think re-declaring the Cursor will be the last resort.

Thanks,
Siva
Back to top
View user's profile Send private message
somnath

New User


Joined: 21 Mar 2005
Posts: 18
Location: India

PostPosted: Wed May 23, 2007 8:45 am
Reply with quote

I think using Dynamic SQL can ease your problem.
Back to top
View user's profile Send private message
Sivagurunathan Jagadeesan

New User


Joined: 06 Mar 2007
Posts: 32
Location: India

PostPosted: Fri May 25, 2007 6:26 am
Reply with quote

Hi,

Thanks a lot for the suggestions, I'll try the dynamic SQL.

Thanks,
Siva
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 JCL EXEC PARM data in C Java & MQSeries 2
No new posts Need to specify PARM='POSIX(ON) Java & MQSeries 4
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts To search DB2 table based on Conditio... DB2 1
This topic is locked: you cannot edit posts or make replies. Merge 2 input files based on the reco... JCL & VSAM 2
Search our Forums:

Back to Top