十万火急!心急如焚!关于存储过程的问题,请高手们救命!
问题如下面蓝色字体所述:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[pro_Mate_Out_CheckNo]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[pro_Mate_Out_CheckNo]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
/*---------------------------------
过程名称:原料出库【反审】
修改内容:
-----------------------------------*/
CREATE PROCEDURE pro_Mate_Out_CheckNo @UserName nvarchar(50)
WITH ENCRYPTION AS
SET XACT_ABORT ON
Begin Transaction
--00 读取参数
Declare @ProcName nvarchar(50)
Declare @BillCode nvarchar(50)
Select @ProcName = 'pro_Mate_Out_CheckNo'
Select @BillCode = FValue
From Base_Procedure
Where FItem = '单号'
And FUserName = @UserName
And FProcName = @ProcName
Declare @Count int --计数器
Declare @Type nvarchar(50) --单据类型
Declare @State nvarchar(50) --单据状态
Select @Type = FType,
@State = FState
From Mate_OutHead
Where FCode = @BillCode
--01 检查数据的完整性和有效性
--0101 单据状态检查
If IsNull(@State,'') <> '审核'
Begin
Rollback
RaisError('操作无效!只有审核的单据才能反审。', 11, 1)
Return
End
--0102 表体物料不能为空
Select @Count = Count(*)
From Mate_OutBody
Where FHead = @BillCode
And IsNull(FMaterialCode,'') = ''
If @Count > 0
Begin
Rollback
RaisError('物料编号有为空的记录,不能反审!', 11, 1)
Return
End
--0103 表体仓位不能为空
Select @Count = Count(*)
From Mate_OutBody
Where FHead = @BillCode
And IsNull(FPlaceName,'') = ''
If @Count > 0
Begin
Rollback
RaisError('仓位有为空的记录,不能反审!', 11, 1)
Return
End
--02 更新库存数据
--0201 增加物料表的数量和金额
Update Mate_Material
Set FAmount = IsNull(FAmount,0) + F1,
FMoney = IsNull(FMoney,0) + F2
From (Select FMaterialCode, Sum(IsNull(FAmount,0)) As F1, Sum(IsNull(FMoney,0)) As F2
From Mate_OutBody
Where FHead = @BillCode
Group By FMaterialCode) As T1
Where FCode = FMaterialCode
&