我有下面存储的prodecure,当我为Gkol传递空值时,我希望将其更改为最小可能的数量(存在于表中),但它不会发生,为什么会这样?
Alter PROCEDURE sp_vUnitsUnitTejariGetFilteredUnitDetail(
@UnitFB bit,
@UnitWithCooking bit,
@MMofidFrom float = null,
@MMofidTo float = null,
@GKolFrom float = null,
@GKolTo float = null
)
AS
BEGIN
declare @MMofidCalculative bit
declare @GKolCalculative bit
if(@MMofidFrom is null)
select @MMofidFrom = MIN(MMofid) from vw_PSA_UnitsUnitTejari
if(@MMofidTo is null)
select @MMofidTo = MAX(MMofid) from vw_PSA_UnitsUnitTejari
if(@GKolFrom is null)
select @GKolFrom = MIN(GKol) from vw_PSA_UnitsUnitTejari
if(@GKolTo is not null)
select @GKolTo = MAX(GKol) from vw_PSA_UnitsUnitTejari
Select * from vw_PSA_UnitsUnitTejari
where UnitTypeID = 1
And UnitStateID = 1
And UnitFB = ISNULL(@UnitFB,UnitFB)
And UnitWithCooking = ISNULL(@UnitWithCooking,UnitWithCooking)
And MMofid between @MMofidFrom and @MMofidTo
And GKol between @GKolFrom and @GKolTo
END
答案 0 :(得分:0)
我弄清楚它为什么不起作用,问题出现在最后一个if块
中if(@GKolTo is not null)
我删除了NOT,一切顺利,谢谢大家