Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Практ 11 цикл loop
- drop procedure pract11;
- create procedure pract11()
- begin
- declare i int default 0;
- set @out = 0;
- za: loop
- select @out := @out + cost * amount from pract11 order by id limit i,1;
- set i = i + 1;
- if i > 2 then leave za; end if;
- end loop za;
- select @out;
- end;
- call pract11()
- # Практ 11 цикл while
- drop procedure pract11;
- create procedure pract11()
- begin
- declare i int default 0;
- set @out = 0;
- za: while i < 3 do
- select @out := @out + cost * amount from pract11 order by id limit i,1;
- set i = i + 1;
- end while;
- select @out;
- end;
- call pract11()
- # Практ 11 цикл repeat
- drop procedure pract11;
- create procedure pract11()
- begin
- declare i int default 0;
- set @out = 0;
- repeat
- select @out := @out + cost * amount from pract11 order by id limit i,1;
- set i = i + 1;
- until i > 2 end repeat;
- select @out;
- end;
- call pract11()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement