ALTER PROCEDURE [dbo].[sp_DelBillProduct]
(
@BPID int
)
AS
BEGIN
declare @BID int,@TotalCount int, @OverCount int,@Flag int
begin tran
delete TBillProduct where BPID = @BPID
select @BID = BID from TBillProduct where BPID = @BPID
select @TotalCount = TotalCount,@OverCount = OverCount,@Flag = Flag from TBill where BID = @BID
if @@error<>0
begin
ROLLBACK TRAN
return
end
if @TotalCount -1 = 0
begin
set @Flag = 1
end
else
begin
if @OverCount = @TotalCount -1
begin
set @Flag = 2
end
end
declare @Remain int
set @Remain = @TotalCount -1
update TBill set TotalCount = @Remain,Flag = @Flag where BID = @BID
-- select @TotalCount-1 as Remain,@OverCOunt,@Flag
if @@error<>0
begin
ROLLBACK TRAN
return
end
commit tran ENDupdate TBill set TotalCount = @Remain,Flag = @Flag where BID = @BID没有执行!
而我测试用select都时正常的。为什么啊?晕啊
(
@BPID int
)
AS
BEGIN
declare @BID int,@TotalCount int, @OverCount int,@Flag int
begin tran
delete TBillProduct where BPID = @BPID
select @BID = BID from TBillProduct where BPID = @BPID
select @TotalCount = TotalCount,@OverCount = OverCount,@Flag = Flag from TBill where BID = @BID
if @@error<>0
begin
ROLLBACK TRAN
return
end
if @TotalCount -1 = 0
begin
set @Flag = 1
end
else
begin
if @OverCount = @TotalCount -1
begin
set @Flag = 2
end
end
declare @Remain int
set @Remain = @TotalCount -1
update TBill set TotalCount = @Remain,Flag = @Flag where BID = @BID
-- select @TotalCount-1 as Remain,@OverCOunt,@Flag
if @@error<>0
begin
ROLLBACK TRAN
return
end
commit tran ENDupdate TBill set TotalCount = @Remain,Flag = @Flag where BID = @BID没有执行!
而我测试用select都时正常的。为什么啊?晕啊
解决方案 »
- 从一个表读出数据, 然后插入到另外一个表
- 这里的 where 100 in 的100怎么理解丫?
- 存储过程
- 求一sql
- 在一个存储过程中,我想这样set @vSeqValue = exec ('select max(col1)+1 from '+@table_name); 但是报错,请帮忙解决
- 存储过程的问题,返回不了变量....
- 麻烦大家看一下这个问题
- 简单关系图的问题
- 请问数据库为什么提示数据库日志已满?
- 如何用vb获取某字段的默认值? 急急急!!
- LouisXIV(夜游神) 请进...............................
- 测试一下自己,看看自己会做这些数据库试题吗。(全部是面试题)。。
谁顶谁得分哈