1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
DECLARE @cursor AS CURSOR
SET nocount ON
DECLARE @noProduit AS varchar(20)
DECLARE @noOf AS varchar(10)
DECLARE @description AS varchar(60)
SET @cursor = cursor for
SELECT DISTINCT ith.tref AS NoOF, ith2.tprod AS Produit, iim.idsclf AS Description, ith2.tlot AS CodeLot
FROM lassonde.dbo.ith ith
JOIN lassonde.dbo.fso fso ON ith.tref = sord
JOIN lassonde.dbo.ith ith2 ON sord = ith2.tref AND sprod = ith2.tprod
JOIN lassonde.dbo.iim iim ON ith2.tprod = iprod
WHERE ith.tlot = @nolot AND ith.ttype IN ('I','M') AND ith.ttype <> 'T' AND ith2.ttype IN ('M','R')
FOR READ only;
OPEN @cursor
FETCH next FROM @cursor INTO @noOF, @noProduit, @description, @noLot
WHILE (@@fetch_status<>0)
BEGIN
IF (@noLot<>'')
EXEC usp_OF_family @noLot
ELSE
INSERT INTO ListeOF VALUES(@noOf, @noProduit, @description)
FETCH next FROM @cursor INTO @noOF, @noProduit, @description, @noLot
END
CLOSE @cursor
DEALLOCATE @cursor
RETURN |
Partager