DEFINITIONS

Definitions More Info.
Definition ID12.107
TitleSQL
CategoryNOTES
Definitioncursor in cursor - icice cursor - nested cursor
Definition Description/*https://stackoverflow.com/questions/469019/cursor-inside-cursor*/

Declare @ClientID int;
Declare @UID int;

DECLARE Cur1 CURSOR FOR
SELECT ClientID From Folder;

OPEN Cur1
FETCH NEXT FROM Cur1 INTO @ClientID;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Processing ClientID: ' + Cast(@ClientID as Varchar);
DECLARE Cur2 CURSOR FOR
SELECT UID FROM Attend Where ClientID=@ClientID;
OPEN Cur2;
FETCH NEXT FROM Cur2 INTO @UID;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT 'Found UID: ' + Cast(@UID as Varchar);
FETCH NEXT FROM Cur2 INTO @UID;
END;
CLOSE Cur2;
DEALLOCATE Cur2;
FETCH NEXT FROM Cur1 INTO @ClientID;
END;
PRINT 'DONE';
CLOSE Cur1;
DEALLOCATE Cur1;
RecordBycunay
Record Date01-10-2023 15:12:58
Düzenle
Kopyala
Sil