Ne zelim da koristim return komandu, jer ima koda posle kursora koji treba da nastavi da se izvrsava.
Znaci imam recimo
Code:
DECLARE abc CURSOR FOR
SELECT ID, name
FROM Customers
OPEN abc
FETCH NEXT FROM abc
INTO @ID, @CustomerName
WHILE @@FETCH_STATUS <> -1
BEGIN
-- check whether got any data
IF @CustomerName IS NULL
BEGIN
-- Exit cursor here
END
-- Do some other things inside cursor....
FETCH NEXT FROM abc
INTO @CustomerName
END
CLOSE abc
DEALLOCATE abc
-- Code that is executed after cursor...
DECLARE abc CURSOR FOR
SELECT ID, name
FROM Customers
OPEN abc
FETCH NEXT FROM abc
INTO @ID, @CustomerName
WHILE @@FETCH_STATUS <> -1
BEGIN
-- check whether got any data
IF @CustomerName IS NULL
BEGIN
-- Exit cursor here
END
-- Do some other things inside cursor....
FETCH NEXT FROM abc
INTO @CustomerName
END
CLOSE abc
DEALLOCATE abc
-- Code that is executed after cursor...
Znaci hocu da izadjem is cursora ako naidjem na rekord koji nema customer name i da nastavim da izvrsavam code iza cursora.
Glup primer al ajde, pokazuje sta mi treba:)
All beer is good. Some beer is better.