Re: pl/sql conditional cursor?
From: steph <stephan0h_at_yahoo.de>
Date: Thu, 4 Jun 2009 02:33:00 -0700 (PDT)
Message-ID: <9672350e-7a41-42ed-93fd-6944db216e96_at_y9g2000yqg.googlegroups.com>
On 4 Jun., 11:05, Peter Kallweit <p_kallw..._at_arcor.de> wrote:
> steph wrote:
> > hi,
>
> > Oracle 10g. In a procedure I have some code like
>
> > declare
> > cursor c1 is
> > select x,y
> > from tab1,tab2
> > where <condition1>
> > and <condition2>
> > and <condition3>;
> > begin
> > for r1 in c1 loop
> > <some code>
> > end loop;
> > end;
>
> > Now I want to turn condition 3 on/off depending on one of the
> > procedure's parameters - without having to define a second cursor
> > (because this would mean duplicating some amount of code). So what I
> > don't want to do is this:
>
> Hi Stephan,
>
> how about
>
> cursor c1 is
> select x,y
> from tab1,tab2
> where <condition1>
> and <condition2>
> and (<parametersaysoff> or <condition3>);
>
> hth
> Peter
Date: Thu, 4 Jun 2009 02:33:00 -0700 (PDT)
Message-ID: <9672350e-7a41-42ed-93fd-6944db216e96_at_y9g2000yqg.googlegroups.com>
On 4 Jun., 11:05, Peter Kallweit <p_kallw..._at_arcor.de> wrote:
> steph wrote:
> > hi,
>
> > Oracle 10g. In a procedure I have some code like
>
> > declare
> > cursor c1 is
> > select x,y
> > from tab1,tab2
> > where <condition1>
> > and <condition2>
> > and <condition3>;
> > begin
> > for r1 in c1 loop
> > <some code>
> > end loop;
> > end;
>
> > Now I want to turn condition 3 on/off depending on one of the
> > procedure's parameters - without having to define a second cursor
> > (because this would mean duplicating some amount of code). So what I
> > don't want to do is this:
>
> Hi Stephan,
>
> how about
>
> cursor c1 is
> select x,y
> from tab1,tab2
> where <condition1>
> and <condition2>
> and (<parametersaysoff> or <condition3>);
>
> hth
> Peter
I'm not sure if this wouldn't possibly degrade performance of my query? At least the execution plan is surely different then when having 2 distinct cursors? Received on Thu Jun 04 2009 - 04:33:00 CDT