title: Case when in Cursor
body: <p>Untested waters,I'm trying to find a way to ease things up. Instead of having a nested select in a cursor in PL-SQL. I'm trying to make a case when in the cursor. Since the cursor can have different inparameters and I need to sort things accordingly. </p>
  
  <p>Is this possible? My code looks like this. It's easy to read ao_in is the Inparam.</p>
  
  <pre><code>PROCEDURE theProcedure (ao_in IN VARCHAR2)
  
  CURSOR order_cur
    IS
   Case when ao_in = 'NIEC' 
    then          
        SELECT t1.nr, t1.status$nr
        FROM eh_order_t@NGEXT_DBLINK t1
        WHERE     t1.status$nr IN (3, 6)
        AND ao_in =
                       DECODE (ao_in, 'NIEC', ao_in, get_ehorder_ao (t1.nr))
                AND t1.nr = DECODE (order_in, NULL, t1.nr, order_in)
       ORDER BY t1.skapad_dat ASC;
  
    when ao_in = 'DSSP'  then
    SELECT t1.nr, t1.status$nr
        FROM eh_order_t@NGEXT_DBLINK t1
        WHERE     t1.status$nr IN (3, 6)
        AND ao_in =
                       DECODE (ao_in, 'DSSP', ao_in, get_ehorder_ao (t1.nr))
                AND t1.nr = DECODE (order_in, NULL, t1.nr, order_in)
       ORDER BY t1.skapad_dat ASC;
    when ao_in = 'ALLA'
  
    SELECT t1.nr, t1.status$nr
        FROM eh_order_t@NGEXT_DBLINK t1
        WHERE     t1.status$nr IN (3, 6)
        AND ao_in =
                       DECODE (ao_in, 'ALLA', ao_in, get_ehorder_ao (t1.nr))
                AND t1.nr = DECODE (order_in, NULL, t1.nr, order_in)
       ORDER BY t1.skapad_dat ASC;
    end
  </code></pre>