数据库存储过程

alter proc Proc_SaleReturn
(
@UId int,
@OId int,
@SaleCase nvarchar(max),
@SImg nvarchar(max),
@Count int out
)
as
begin
begin try
begin tran

insert into SaleInfoes values(@OId,@SaleCase,@SImg)
set @Count=@@rowcount
update OrdersInfoes set OState=3
set @Count+=@@rowcount
update GoodsInfoes set GNum+=(select ONum from OrdersInfoes where OId=@OId and UId=@UId) where GId=(select GId from OrdersInfoes where OId=@OId and UId=@UId)
set @Count+=@@rowcount
commit tran
end try

begin catch
rollback tran
set @Count=0
end catch
return @Count
end

declare @C int
exec Proc_SaleReturn 1,3,'不想要','/Upload/3.png',@C out
select @C


select * from OrdersInfoes as o join GoodsInfoes as g on o.GId=g.GId
join UsersInfoes as u on o.UId=u.UId where u.UId=1

posted @ 2020-07-09 19:52  N_o  阅读(20)  评论(0编辑  收藏  举报