Oracle PL/SQL - Are NO_DATA_FOUND Exceptions bad for stored procedure performance?

后端 未结 12 878
Happy的楠姐
Happy的楠姐 2021-02-03 23:14

I\'m writing a stored procedure that needs to have a lot of conditioning in it. With the general knowledge from C#.NET coding that exceptions can hurt performance, I\'ve always

12条回答
  •  遇见更好的自我
    2021-02-03 23:57

    you dont have to use open when you are using for loops.

    declare
    cursor cur_name is  select * from emp;
    begin
    for cur_rec in cur_name Loop
        dbms_output.put_line(cur_rec.ename);
    end loop;
    End ;
    

    or

    declare
    cursor cur_name is  select * from emp;
    cur_rec emp%rowtype;
    begin
    Open cur_name;
    Loop
    Fetch cur_name into  Cur_rec;
       Exit when cur_name%notfound;
        dbms_output.put_line(cur_rec.ename);
    end loop;
    Close cur_name;
    End ;
    

提交回复
热议问题