Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Want to declare 3 cursors for 3 conditions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Nov 28, 2006 1:46 pm    Post subject: Want to declare 3 cursors for 3 conditions
Reply with quote

i have a cursor declared as
declare c1 cursor for
select name,empno,empdept
from table
where
name = :ws-name
and empno =:ws-empno
and dept = :ws-dept

now depending on an input condition the where clause will change ...it can use 3 keys ....if 3 keys are thr in input or else 1st and 3rd or 2 nd and 3rd

i dont want to declare 3 cursors for 3 conditions ....
if only name and empno is thr in input and thr is no value for dept the where clause shud have only name and empno ...

is thr any way out of this ...
if i can use dynamic sql how do i declare it .....open and fetch ....
pls help
Back to top
View user's profile Send private message

UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 757
Location: Germany

PostPosted: Tue Nov 28, 2006 5:41 pm    Post subject:
Reply with quote

Hi !

For a quick and easy entry in DynamicSQL please look at http://www.craigsmullins.com/dbu_1004.htm.

But remenber that dynamic sql is increasing performance !!!

In a lot of companies with the need of high performance applications it's forbidden to use dynamic sql.

So just make it easy. Define three cursors and a few minutes later, your work is done.

Regards, UmeySan
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Nov 30, 2006 11:29 am    Post subject:
Reply with quote

thanks umey for ur response ..... but here the above cursor was just an example .....actually the where clause contains 6 keys ..and in total i shud declare 18 cursors which is goin to give a huge bind ....
neways i figured out a way for this ...
u can declare the cursor as below ...
declare c1 cursor for
select name,empno,empdept
from table
where
( name = :ws-name or name = ' ')
and ( empno =:ws-empno or empno = ' ' )
and ( dept = :ws-dept or dept = ' ')

this worked fine .........
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 Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm
No new posts DFSORT report with multiple conditions Bill Woodger DFSORT/ICETOOL 9 Wed Jan 20, 2016 2:19 am
No new posts Conditions on SORT to avoid extra space vicharapusrinu JCL & VSAM 17 Thu Jan 16, 2014 1:29 pm
No new posts How to declare ABC PIC 9(3) in assem... Pavankumar.m PL/I & Assembler 2 Thu Oct 03, 2013 4:29 pm
No new posts How to declare 9(4) comp-5 field in a... Pavankumar.m PL/I & Assembler 3 Fri Jul 19, 2013 3:16 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us