ALTER PROCEDURE [dbo].[K_HM_InsertSetterGetterAllocationDet]
@type varchar(50),
@name varchar(50),
@settingdate datetime,
@quantity int,
@Batchno varchar(50),
@pulloutdate datetime,
@supervisor varchar(50),
@updatedby varchar(50)
AS
BEGIN
SET NOCOUNT ON;
if exists(select * from K_HM_SetterGetterAllocationDet where Name=@name and [type]=@type and Attrited='false')
begin
select '1' as status
end
else
if exists (select * from K_HM_GetterSetterDet where Capacity >=@quantity)
begin
select '2' as status
end
else
insert into K_HM_SetterGetterAllocationDet (Type, Name, Settingdate, Quantity, batchno,pulloutdate,Supervisor,Attrited,Updatedby,Updatedon)
values (@type, @name, @settingdate, @quantity, @Batchno, @pulloutdate, @supervisor, 'false', @updatedby, getdate())
select '3' as status
END
上記の手順では、上記の 2 つのケースが false で、Quantity が Capacity より小さい場合、3 番目のケースは実行されません。数量が容量より少ないか多い場合は、常に 2 番目のケースにのみ入ります。私の手順で何が問題なのですか、助けてください....