小弟有个存储过程,要实现这个功能:
查询某个表,
如果其中的某个字段为1,则想用mycursor1
如果其中的某个字段为2,则想用mycursor2如何处理?
问题很低,千万别笑话

解决方案 »

  1.   

    create or replace procedure proc_name
    as
    cursor cursor1
    is
    select * from tb_name where 你说的字段=1 and ...;
    cursor cursor2
    is 
    select * from tb_name where 你说的字段=2 and ...;
    begin
     for c_cursor1 in cursor1 loop
       ...;
     end loop;
     for c_cursor2 in cursor2 loop
       ...;
     end loop;
    exception
     when others then
         dbms_output.put_line('error;'||sqlerrm);
    end proc_name;