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
 

 

SQL WHERE clause should be based on the JCL Parm value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: SQL WHERE clause should be based on the JCL Parm value
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: 436
Location: chennai, India

PostPosted: Tue May 22, 2007 9:35 pm    Post subject:
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    Post subject: Re: SQL WHERE clause should be based on the JCL Parm value
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    Post subject: Re: SQL WHERE clause should be based on the JCL Parm value
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    Post subject: Re: SQL WHERE clause should be based on the JCL Parm value
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    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 Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


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