可以!我学的不好,不过我倒可以把我些的这些小菜给你看看,参考一下吧,我是用的MSSQL
alter proc DeleteInYarn--这是一个删除记录,并同时修改库存表的一个代码
--create proc DeleteInYarn
@ID int
as
declare @Factory nchar(8),
@YarnName nchar(30),
@LotNo nchar(20),
@Box int,
@Weight numeric(12, 4)
select @Factory = Factory,
@YarnName = YarnName,
@LotNo = LotNo,
@Box = Box,
@Weight = Weight
from InYarn
where No = @ID
--开始修改事务
begin transaction
update StoreYarn
set Box = Box - @Box,
Weight = Weight - @Weight
where Factory = @Factory
and YarnName = @YarnName
and LotNo = @LotNO
if @@error <> 0
begin
rollback tran
return 1 --修改库存失败
end
delete from InYarn where No = @ID
if @@error <> 0
begin
rollback tran
return 2 --删除记录失败
end
commit tran
return 0
go
--下面的这个主要是得到当天的出库记录,也可以得到任何一天的出库记录,你只要传递参数就可以了。
--alter procedure GetTodayOutYarn
create procedure GetTodayOutYarn
@FromDate smalldatetime, --
@RowCount int output
as
select * from OutYarn
where OutDate >= @FromDate
set @RowCount = @@RowCount
return 0
go
要是有问题,发我mail吧,我这里慢。lvfugao@hotmail.com