WHILE cikl izpolnatesa tolko 3 raza

GatisK

nu nekak nemogo ponjat pocenu WHILe cikl izpolnaets tolko 3 raza daze napisat skazem WHILE @x < 20 BEGIN ........ ENDMne on izpolnaets neboslhe 3 raz. esli pisatj <3 to vsjo - 2 raza.vot fragment vnesnij cikl dolzen izpolnitsa 4 razaWHILE @xa <5SET @xa=1BEGINSET @Maina=1 WHILE @Maina < 3 BEGIN declare lob_cursor cursor SCROLL FOR select COUNT(ID_lob) As Skaits, AVG(KOR * 0.2) As Cil_D_cm, AVG(Rul * 0.2) As Serd_D_cm, AVG(PI() * (1.0 * MinR * MinR + 1.0 * MinR * MaxR + 1.0 * MaxR * MaxR) * Len * 0.001 * 0.000001/3) As Kon_V_m3, AVG(Pi() * KOR * KOR * Len * 0.001 * 0.000001) AS Cil_V_m3, AVG(Pi() * Rul * Rul * Len * 0.001 * 0.000001) AS Serd_V_m3, AVG(((PI() * KOR * KOR * Len) - (PI() * Rul * Rul * Len)) * 0.001 * 0.000001) AS Nolob_V_m3, AVG((PI() * KOR * KOR * Len - PI() * Rul * Rul * Len) / (1.57 * Len) * 0.1) AS Skaidas_len_cm, AVG((PI() * KOR * KOR * Len - PI() * Rul * Rul * Len) / (PI() * KOR * KOR * Len)) AS Nolob_V_pret_Cil_V, AVG((PI() * KOR * KOR * Len - PI() * Rul * Rul * Len) / (PI() * (1.0 * MinR * MinR + 1.0 * MinR * MaxR + 1.0 * MaxR * MaxR) * Len / 3)) AS Nolb_V_pret_Kon_V from llobcehs.dbo.lob where DATEPART(day, dat)=@diena AND DATEPART(month, dat)=@men AND DATEPART(year, dat)=@gads AND Maina=@MainaOPEN lob_cursor FETCH FROM lob_cursor WHILE @@FETCH_STATUS=0 BEGIN FETCH FIRST FROM lob_cursor INTO @Skaits, @Cilindra_D_cm, @Serdena_D_cm, @Konusa_V_m3, @Cilindra_V_m3, @Serdena_V_m3, @Nolobitais_V_m3, @Skaidas_Len_cm, @Nolob_V_pret_Cil_V, @Nolob_V_pret_Kon_Vinsert into lob_avg(Maina,Skaits, Cilindra_D_cm, Serdena_D_cm, Konusa_V_m3, Cilindra_V_m3, Serdena_V_m3, Nolobitais_V_m3, Skaidas_Len_cm, Nolob_V_pret_Cil_V, Nolob_V_pret_Kon_V ) values (@Maina, @Skaits, @Cilindra_D_cm, @Serdena_D_cm, @Konusa_V_m3, @Cilindra_V_m3, @Serdena_V_m3, @Nolobitais_V_m3, @Skaidas_Len_cm, @Nolob_V_pret_Cil_V, @Nolob_V_pret_Kon_V) FETCH NEXT FROM lob_cursor INTO @nev_datums END CLOSE lob_cursor DEALLOCATE lob_cursorSET @Maina=@Maina + 1 ENDSET @peld_datums=DATEADD(day, 1, @peld_datums) SET @diena=DATEPART(day, @peld_datums) SET @men=DATEPART(month, @peld_datums) SET @gads=DATEPART(year, @peld_datums) SET @xa=@xa + 1END
2 ответа

GatisK

WHILE @xa <5SET @xa=1
ИМХО - местами надо поменять


GatisK

Declare @x int

Set @x = <b>1</b>
While @x <= <b>5</b>
begin
	print @x
	Set @x = @x + <b>1</b>
end
?