oracle。编程序给emp表中的所有员工涨工资30%,但是工资增涨额1000元封顶。 用PL⼀SQL怎么做?

是oracle数据库的
2025-03-25 22:38:16
推荐回答(4个)
回答1:

写个函数直接调用就好了。
function f_add_sarlary(sarlary number) return number is
v_result number default null;
begin
case when sarlary*0.3<1000 then sarlary+sarlary*0.3;
when sarlary*0.3>=1000 then sarlary+1000;
else v_result := null;
end case
return(v_result);
end f_add_sarlary ;

回答2:

标准T-SQL92, 供参考:
update 工资表 set 工资=(case
when 工资*0.3>=1000 then 工资+1000
else 工资*1.3 end)

回答3:

update emp set sal=(case when sal*0.3>1000 then sal+1000 else sal+sal*0.3 end)

回答4:

update emp set sal =sal*1.3 where sal*0.3<1000;