在一个存储过程里面执行另一个存储过程的应用
代码
代码
ALTER PROCEDURE [dbo].[VoucherOutBound_BackInsurance]
-- Add the parameters for the stored procedure here
@IU_Id int,
@ICC_ID int,
@IC_ID int,
@UV_CurrentNO varchar(25),
@UV_VMoney decimal(18,2)
AS
DECLARE @snum bigint, @fnum bigint,@VO_StartNumber varchar(25),@outNumber varchar(25),@newCuid bigint,@nextVum varchar(25),@dt datetime,@count int
BEGIN tran
--查询需要插入的下一条记录
set @snum = CAST(substring(@outNumber,7,len(@outNumber)) as bigint)+1
set @nextVum =substring(@outNumber,1,6) + REPLICATE('0',len(@outNumber)-len(@snum)-6)+ cast(@snum as varchar(16))
set @dt=getdate()
--执行添加的存储过程
a_Add 这个是存储过程的名,后面的都是参数 ,@count=@count 这个是输出参数
EXEC a_Add @IC_Id=@IC_Id,@ICC_Id=@ICC_Id,@VO_StartNumber=@outNumber,@VO_StopNumber=@outNumber,@VO_Number=1,@IU_Id=@IU_Id,@VO_CreateDate=@dt,@VO_State=2,@VO_NextOutNum=@nextVum,@count=@count
EXEC b_Add @IC_Id=@IC_Id,@ICC_Id=@ICC_Id,@VC_VoucherNumber=@UV_CurrentNO,@VC_Underwrite=@dt,@IU_Id=@IU_Id,@VC_CreateDate=@dt,@count=@count
if(@@ERROR<>0)
BEGIN
PRINT '有错误,回滚'
ROLLBACK tran --事务回滚语句
END
ELSE
BEGIN
PRINT '成功,提交'
COMMIT tran --事务提交语句
end
ALTER PROCEDURE [dbo].[VoucherOutBound_BackInsurance]
-- Add the parameters for the stored procedure here
@IU_Id int,
@ICC_ID int,
@IC_ID int,
@UV_CurrentNO varchar(25),
@UV_VMoney decimal(18,2)
AS
DECLARE @snum bigint, @fnum bigint,@VO_StartNumber varchar(25),@outNumber varchar(25),@newCuid bigint,@nextVum varchar(25),@dt datetime,@count int
BEGIN tran
--查询需要插入的下一条记录
set @snum = CAST(substring(@outNumber,7,len(@outNumber)) as bigint)+1
set @nextVum =substring(@outNumber,1,6) + REPLICATE('0',len(@outNumber)-len(@snum)-6)+ cast(@snum as varchar(16))
set @dt=getdate()
--执行添加的存储过程
a_Add 这个是存储过程的名,后面的都是参数 ,@count=@count 这个是输出参数
EXEC a_Add @IC_Id=@IC_Id,@ICC_Id=@ICC_Id,@VO_StartNumber=@outNumber,@VO_StopNumber=@outNumber,@VO_Number=1,@IU_Id=@IU_Id,@VO_CreateDate=@dt,@VO_State=2,@VO_NextOutNum=@nextVum,@count=@count
EXEC b_Add @IC_Id=@IC_Id,@ICC_Id=@ICC_Id,@VC_VoucherNumber=@UV_CurrentNO,@VC_Underwrite=@dt,@IU_Id=@IU_Id,@VC_CreateDate=@dt,@count=@count
if(@@ERROR<>0)
BEGIN
PRINT '有错误,回滚'
ROLLBACK tran --事务回滚语句
END
ELSE
BEGIN
PRINT '成功,提交'
COMMIT tran --事务提交语句
end