* 구구단
begin
for i in 2..9 loop
for j in 1..9 loop
p(i || ' * ' || j || ' = ' || i*j);
end loop;
p(' ');
p('------------');
p(' ');
end loop;
end;
/
* Label
declare
v_sum number := 0;
i number := 1;
j number;
begin
-- i := 1;
<<Outside>>
loop
i := i + 1;
j := 0;
exit when i > 9;
<<Inside>>
loop
j := j + 1;
v_sum := v_sum + i * j;
p(to_char(i)||' * '||to_char(j)
||' = '||to_char(i*j)||', sum = '||to_char(v_sum));
exit outside
when v_sum > 1000; --> label is case-insensitive
exit when j >= 9;
end loop inside; --> label is for clarity
end loop; --outside; --> label is optional
end;
/
'Oracle > PL/SQL' 카테고리의 다른 글
15일차 # 확인문제 (0) | 2012.04.24 |
---|---|
15일차 # 5-29: Sequential Control: GOTO and NULL Statements (0) | 2012.04.24 |
15일차 # 5-22: FOR Loop (0) | 2012.04.24 |
15일차 # 5-20: WHILE Loop (0) | 2012.04.24 |
15일차 # 5-18: Basic Loop (0) | 2012.04.24 |