我确信解决方案是一种非常简单的解决方案,但我一直在寻找
SqlException:过程或函数需要未提供的参数
错误。我不是SQL向导,但对我来说参数看起来没问题。我确实更改了参数并且没有收到此错误,但是当我一直开始接收它时,我将存储过程恢复到原来的版本,我知道这个事实很好但仍然接收它。
我尝试像这样执行存储过程
EXECUTE [dbo].[BHS_CloseCnt_Print_PackList] @palletid = '562992'
填入变量。此存储过程调用一个函数来确定订单的状态,如果我插入的变量并使用此方法检查符合函数的条件,我得到预期的返回。
如果容器尚未达到功能标准,我会得到一个null,我认为没问题。
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[BHS_CloseCnt_Print_PackList]
(@PalletId numeric)
AS
BEGIN
Declare @PO as nvarchar(50)
Declare @Internal_Shipment_Num as numeric
Declare @Internal_Shipment_Line_Num as numeric
select top 1
@Internal_Shipment_Num = sc.INTERNAL_SHIPMENT_NUM,
@Internal_Shipment_Line_Num = sc.INTERNAL_SHIPMENT_LINE_NUM
from
SHIPPING_CONTAINER sc
where
INTERNAL_CONTAINER_NUM = @PalletId
or PARENT = @PalletId
and INTERNAL_SHIPMENT_LINE_NUM is not null
select @PO = dbo.fn_BHS_AllPOPLTS_CLOSED(@PalletId, @Internal_Shipment_Num, @Internal_Shipment_Line_Num)
print @PO
if @PO is not null
Begin
select @PalletId 'INTERNAL_CONTAINER_NUM', '60' 'DOCUMENT_TYPE'
End
End
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_BHS_AllPOPLTS_CLOSED]
(@palletId numeric,
@Internal_Shipment_Num numeric,
@Internal_Shipment_Line_Num numeric)
RETURNS nvarchar(50)
AS
BEGIN
Declare @PO nvarchar(50)
Declare @OPENPO nvarchar(50)
Declare @IntShip as numeric
select @PO = isnull(sd.CUSTOMER_PO, 'FEIT')
from SHIPMENT_DETAIL sd
where sd.INTERNAL_SHIPMENT_LINE_NUM = @Internal_Shipment_Line_Num
and sd.internal_shipment_num = @Internal_Shipment_Num
select @OPENPO = isnull(sd.CUSTOMER_PO, '')
from shipping_container sc
join SHIPMENT_DETAIL sd on sd.INTERNAL_SHIPMENT_LINE_NUM = sc.INTERNAL_SHIPMENT_LINE_NUM
where sd.CUSTOMER_PO = @PO and sc.INTERNAL_SHIPMENT_NUM = @Internal_Shipment_Num
and sc.status < 600
if(isnull(@OPENPO, '') != '')
Begin
set @PO = null
End
return @PO
End
答案 0 :(得分:0)
虽然恢复了已知的工作版本,但存储过程看起来已经存储了我之前编辑的缓存。
对此的解决方法是运行DBCC FREEPROCCACHE来清除存储过程缓存,并且我能够按预期执行。
感谢Nemanja Perovic!