pl/sql conditional cursor?

From: steph <stephan0h_at_yahoo.de>
Date: Thu, 4 Jun 2009 01:38:34 -0700 (PDT)
Message-ID: <a683e9a3-af38-4242-a487-a56e7d5cd66f_at_37g2000yqp.googlegroups.com>



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:

declare
  cursor c1 is
  select x,y

     from tab1,tab2
   where <condition1>

      and <condition2>
      and <condition3>;

  cursor c2 is
  select x,y

     from tab1,tab2
   where <condition1>

      and <condition2>;
begin
  ...
end;

How can I achieve this?

Thanks,
Stephan Received on Thu Jun 04 2009 - 03:38:34 CDT

Original text of this message