Hey all,
I have this Stored Procedure that works well but for some reason the first @@RowCount does not seem to work. Instead of giving me @Reject, '03' , and '000' it gives me all nulls when I search for a UCC_bc that does not exist in UCC. The other RowCounts work fine, but I can not see what the difference is, but I dont know much about SQL so.
Thanks
-Bill
I have this Stored Procedure that works well but for some reason the first @@RowCount does not seem to work. Instead of giving me @Reject, '03' , and '000' it gives me all nulls when I search for a UCC_bc that does not exist in UCC. The other RowCounts work fine, but I can not see what the difference is, but I dont know much about SQL so.
Thanks
-Bill
Code:
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @Reject = LaneMap FROM dbo.LaneMappingTable1 WHERE Customer = 'Reject' AND Destination = 'Reject'
SELECT @Retailer = Retailer, @Customer = Customer, @ContainerNum = ContNum FROM dbo.Details WHERE CartonID = @UCC_BC
-- Insert statements for procedure here
SELECT @DCID = DCID, @DCIDMode = DCIDMode FROM dbo.SortRules WHERE (UCCMode = 'S' AND UCC = @UCC_bc)
If @@RowCount = 0
Begin
SELECT @Lane = @Reject, @ReasonCode = '03', @UniqueID = '000' FROM dbo.SortRules WHERE (UCC = @UCC_bc)
End
Else
IF @DC_bc = @DCID AND @DCIDMode = 'V'
Begin
SELECT @CustOut = CustOut, @Destination = Dest, @SortUniqueID = UniqueID FROM dbo.sortRules WHERE (UCC = @UCC_bc)
SELECT @Lane = LaneMap, @ReasonCode = '00', @UniqueID = @SortUniqueID
from dbo.LaneMappingTable1
where Customer = @CustOut
and Destination = @Destination
If @@RowCount = 0
SELECT @Lane = @Reject, @ReasonCode = '04', @UniqueID = @SortUniqueID FROM dbo.SortRules WHERE (UCC = @UCC_bc)
End
ELSE IF @DCIDMode = 'V' AND @DC_bc <> @DCID
Begin
SELECT @CustOut = CustOut, @Destination = Dest, @SortUniqueID = UniqueID FROM dbo.sortRules WHERE (UCC = @UCC_bc)
SELECT @Lane = @Reject, @ReasonCode = '02', @UniqueID = @SortUniqueID
from dbo.LaneMappingTable1
where Customer = @CustOut
and Destination = @Destination
If @@RowCount = 0
SELECT @Lane = @Reject, @ReasonCode = '04', @UniqueID = @SortUniqueID FROM dbo.SortRules WHERE (UCC = @UCC_bc)
End
ELSE
Begin
SELECT @CustOut = CustOut, @Destination = Dest, @SortUniqueID = UniqueID FROM dbo.SortRules WHERE (UCC = @UCC_bc)
SELECT @Lane = LaneMap, @ReasonCode = '01', @UniqueID = @SortUniqueID
from dbo.LaneMappingTable1
where Customer = @CustOut
and Destination = @Destination
If @@RowCount = 0
SELECT @Lane = @Reject, @ReasonCode = '04', @UniqueID = @SortUniqueID FROM dbo.SortRules WHERE (UCC = @UCC_bc)
End
END