create or replace package comm_pkg is
std_comm number := 0.10; --- 变量
procedure reset_comm(new_comm number); --- 存储过程
end comm_pkg;
/
create or replace package body comm_pkg is
function validate(comm number) return boolean is ---- 包体 内部校验 function
max_comm employees.commission_pct%type;
begin
select max(commission_pct) into max_comm from employees;
return (comm between 0.0 and max_comm);
end validate;
procedure reset_comm(new_comm number) is ---- 已在 包头 声明 的 存储过程
begin
if validate(new_comm) then
std_comm:=new_comm;
else raise_application_error(-20210,'bad commission');
end reset_comm;
end comm_pkg;
/ execute hr.comm_pkg.reset_comm(0.15);
本文介绍了如何在数据库中通过存储过程动态调整员工佣金比例,并验证调整是否在合理范围内。
4751

被折叠的 条评论
为什么被折叠?



