规则 5.7:当程序有多个分支返回时,要确保各个分支都结束了事务。但是,禁止在没有事务的代码中,随意使用rollback、commit。
create or replace procedure p_procedurename (
cur_returnset out pkg_service.resultset --返回结果集
)
as
begin
open cur_returnset
for select column
from t_tablename
where column1 = value;
exception
when others then
open cur_returnset
for select null
from dual
where 1 = 0;
end;
多余的提交会使数据库产生过多的log file sync等待,降低了系统的整体性能。
规则 5.8:不能用no_data_found异常来处理max、min、sum、avg等函数,因为在没有找到任何匹配条件的记录时,这些函数返回的是NULL,而不会抛no_data_found异常。
规则 5.9:存储过程、函数的参数以及声明的变量要确保都被使用。
规则 5.10:避免通过dual表赋值。
dt_l_date := sysdate;