Oracle
 sql >> Base de données >  >> RDS >> Oracle

Comment renvoyer plusieurs lignes d'une procédure stockée oracle à partir de plusieurs curseurs ?

Ma suggestion va être d'insérer les lignes de votre curseur dans une table temporaire. Joignez ensuite la table temporaire à votre table existante pour les critères de filtre que vous mentionnez. Pseudocode :

create or replace function my_func
return sysrefcursor
is
    cursor cursor_one is 
        SELECT * FROM table_one ; 

    cursor cursor_two is 
        SELECT * FROM table_one ; 
    BEGIN    

     FOR current_row in cursor_one
      loop 

          -- do some modification on each row and insert into temporary table

      end loop; 



     FOR current_row in cursor_two
      loop 

          -- do some modification on each row and insert into temporary table

      end loop; 


    -- results from cursor 1 and 2 exist in temporary table

    open out_cursor for
     select t.* from
      my_temp_table t
      join
      my_other_table tt
      on (t.col1 = tt.col1) -- or whatever columns are appropriate
      where t.col2 = 'some criteria' -- or whatever filter criteria you like.

    return out_cursor;

    END;