如何实现简单的入库功能
rkmx-入库明细表 PH可以空
rkbh goodsid goodsqty ph bumenid
-------------------------------------------------------------------
入库单 商品ID 入库数量 批号 入库部门ID
-------------------------------------------------------------------
1 2 1 2007 6000000
2 2 2 20091001 6000000
3 6 20 5000000
3 7 30 200101 5000000
--------------------------------------------------------------
kcb---库存表
goodsid bumenid kcshl
\
如何实现
当我新增一张单时,判断这张单据内的商品是否在KCB有记录,如果有,账更新库存数量
如果没有,则新增GOODSID及库存数量
?
如果是更新,
用如下的方法
string ls_sql
ls_sql = "update zp_kcb
a set kcshl=(select b.goodsqty from rkmx b
where a.goodsid=b.goodsid and b.rkbh=4 )
where exists ( select b.goodsqty from rkmx b
where a.goodsid=b.goodsid and b.rkbh=4)"
EXECUTE IMMEDIATE :ls_sql ;
IF sqlca.sqlcode = 0 then
commit;
else
rollback;
messagebox('错误','err')
end if
运行的速度是好慢,但是我不懂B.rkbh=4
怎么换成动态的单号
有什么更好的方法?