View previous topic :: View next topic
|
Author |
Message |
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
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 |
|
|
radhakrishnan82
Active User
Joined: 31 Mar 2005 Posts: 435 Location: chennai, India
|
|
|
|
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 |
|
|
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
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 |
|
|
somnath
New User
Joined: 21 Mar 2005 Posts: 18 Location: India
|
|
|
|
I think using Dynamic SQL can ease your problem. |
|
Back to top |
|
|
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Hi,
Thanks a lot for the suggestions, I'll try the dynamic SQL.
Thanks,
Siva |
|
Back to top |
|
|
|