STRING ls_goodscode
INTEGER li_stroe_qty
ls_goodscode = st.text
if len(ls_goodscode) = 17 then
DECLARE pstore_goods PROCEDURE FOR pd_store_goods(:ls_goodscode ) ;
// 从库存数中减去 2
execute pstore_goods;
if SQLCA.SLQCODE < 0 then
ROLLBACK ;
messagebox("系统提示", "数据操作有误,请稍候再试!",stopsign! ok!);
end if
else
messagebox("系统提示", "数据输入有误!",information!, ok!);
end if
//同时在当前的FROM WINDOW中的CLOSEQUERY中显示写明ROLLBACK ;
在服务器端
-- procedure pd_store_goods
create or replace procedure pd_store_goods ( ls_goodscode in varchar2 )
IS
ln_store_qty number(10) ;
begin
SELECT nvl(QTY, -1)
INTO ln_store_qty
FROM AMS.TAB_STORE_GOODS_INFO
WHERE GOODS_NO = SUBSTR(ls_goodscode , 1, 13)
AND SERIAL_NO = SUBSTR(ls_goodscode , 14, 4)
FOR UPDATE NOWAIT;
if ln_store_qty >= 2 then
UPDATE AMS.TAB_STORE_GOODS_INFO
SET QTY = ln_store_qty - 2
WHERE GOODS_NO = SUBSTR(ls_goodscode , 1, 13)
AND SERIAL_NO = SUBSTR(ls_goodscode , 14, 4);
COMMIT ;
else
ROLLBACK ;
RAISE_APPLICATION_ERROR(-200002, 'store not enougth!');
end if;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-200001, 'store not SCUESSCULL!');
end ;