<샘플코드에서 사용한 데이터는 HR 스키마이고, 오라클 설치시 생성할 수 있는 기본 스키마 입니다>
declare
v_counter number:=1;
begin
while v_counter<=3
loop
dbms_output.put_line('welcome');
v_counter:=v_counter+1;
dbms_output.put_line('after v_counter+1: '|| v_counter);
end loop;
end;
----------------------------------------------------------------
welcome
after v_counter+1: 2
welcome
after v_counter+1: 3
welcome
after v_counter+1: 4
# print the employees first name for employee 100,101,102
# using while loop
declare
v_empno number:=100;
v_first_name employees.first_name%type ;
begin
while v_empno<=102
loop
select first_name into v_first_name
from employees
where employee_id = v_empno;
dbms_output.put_line(v_empno ||' '|| v_first_name);
v_empno:=v_empno+1;
end loop;
end;
---------------------------------------------------------
100 Steven
101 Neena
102 Lex
'Database > PLSQL' 카테고리의 다른 글
011 - [Oracle PL/SQL] Nested Loops and Labels (0) | 2024.02.09 |
---|---|
010 - [Oracle PL/SQL] For Loop (0) | 2024.02.09 |
008 - [Oracle PL/SQL] Basic Loop (0) | 2024.02.08 |
007 - [Oracle PL/SQL] CASE expression & CASE Statement (0) | 2024.02.08 |
006 - [Oracle PL/SQL] IF Statement (1) | 2024.02.08 |