Link to home
Create AccountLog in
Avatar of Nabilbahr
NabilbahrFlag for United States of America

asked on

nested while in sql functions or stored procedures

hi
I'm trying to nest a while statement inside another while statement
Is that possible?
ASKER CERTIFIED SOLUTION
Avatar of TheAnvilGroup
TheAnvilGroup
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Nabilbahr

ASKER

The problem here is that the nested while is inside if statement
WHILE @x <= 6
		BEGIN
        select @Intgr  = t from @Arr where i = @x
	


			if @Intgr > 0 
				BEGIN
				UPDATE @Arr SET t = 1 WHERE i = 0
				UPDATE @Arr SET t = (select t from @ArrValues where i = @x) WHERE i = 1
				UPDATE @Arr SET t = (select t2 from @ArrValues where i = @x) WHERE i = 2
				END
				ELSE
				BEGIN
					set @bFlag = 0


	
		
		            Declare @j as int
					SET @j = 0
					declare @u as int
					select @u = t2 from @Arr where i = 6 --UBOUND array is 6
					--FOR NEXt
					WHILE @j < @u
					DECLARE @COMP1 AS INT
					DECLARE @COMP2 as INT  
					SELECT @COMP1 = dbo.GetStringingSupport(@j) from @arr where i = 1

                    



					END --while nested


				END

Open in new window