17,089
社区成员
发帖
与我相关
我的任务
分享
create or replace procedure SaleOut(goodNo VARCHAR2, outAmount NUMBER)
As
amount number;
Begin
select Gamount into amount from Goods where Gno=goodNo;
if (amount=0 or amount < outAmount)then
roll back;
end if;
Update Goods Set Gamount=Gamount-outAmount where Gno=goodNo;
commit;
exception
when others then
--此处应捕获一下异常,因为如果select Gamount into amount from Goods where Gno=goodNo语句没有查询出
--满足条件的记录时,会抛出异常
null;
end;