--异常处理1
declare
v_price number(10,2);--单价
v_usenum2 number(10,2);--吨数
v_money number(10,2);--金额
v_account t_account%rowtype;--台帐行记录类型
begin
v_price:=2.45;--单价赋值
-- v_usenum:=9999;--水费字数
select into v_account from t_account
where year='2012' and month='01' and ownerid=200;
v_usenum2:=round(v_account.usenum/1000,2);--吨数
v_money:=v_usenum2v_price;--金额
dbms_output.put_line('水费字数:'||v_account.usenum||'金额:'||v_money);
exception
when no_data_found then
DBMS_OUTPUT.put_line('没有数据');
end;
--异常处理2
declare
v_price number(10,2);--单价
v_usenum2 number(10,2);--吨数
v_money number(10,2);--金额
v_account t_account%rowtype;--台帐行记录类型
begin
v_price:=2.45;--单价赋值
select into v_account from t_account
where year='2012' ;
v_usenum2:=round(v_account.usenum/1000,2);--吨数
v_money:=v_usenum2v_price;--金额
dbms_output.put_line('水费字数:'||v_account.usenum||'金额:'||v_money);
exception
when no_data_found then
DBMS_OUTPUT.put_line('没有数据');
when too_many_rows then
DBMS_OUTPUT.put_line('返回多行');
end;
还没有评论,来说两句吧...