数据库oracle进阶练习01

declare
a int:=9;
b int:=0;
begin
dbms_output.put_line('商是: '||a/b);
dbms_output.put_line('finished!!!');
exception
when zero_divide then
dbms_output.put_line('你做除法时,注意除数不能为0!!!');
dbms_output.put_line('sqlcode||sqlerrm');
end;

declare
v_bonus salary.奖金%type;
v_empid employee.员工编号%type:=20220107;
begin
select 奖金 into v_bonus from salary where 员工编号 = v_empid;
dbms_output.put_line('编号为'||v_empid||v_empid||'的奖金是:'||v_bonus);
exception
when no_data_found then
dbms_output.put_line('此员工编号: '||v_empid||'不存在');
dbms_output.put_line(sqlcode||sqlerrm);
when too_many_rows then
dbms_output.put_line('此员工有多个奖金,不能多给一个变量!');
dbms_output.put_line(sqlcode||sqlerrm);
when others then
dbms_output.put_line(sqlcode||sqlerrm);
end;

SQL> declare
  2  v_bonus salary.奖金%type;
  3  v_empid employee.员工编号%type:=20220107;
  4  begin
  5  select 奖金 into v_bonus from salary where 员工编号 = v_empid;
  6  dbms_output.put_line('编号为'||v_empid||v_empid||'的奖金是:'||v_bonus);
  7  exception
  8  when no_data_found then
  9  dbms_output.put_line('此员工编号: '||v_empid||'不存在');
 10  dbms_output.put_line(sqlcode||sqlerrm);
 11  when too_many_rows then
 12  dbms_output.put_line('此员工有多个奖金,不能多给一个变量!');
 13  dbms_output.put_line(sqlcode||sqlerrm);
 14  when others then
 15  dbms_output.put_line(sqlcode||sqlerrm);
 16  end;
 17  /
编号为2022010720220107的奖金是:20000

PL/SQL 过程已成功完成。
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值