<샘플코드에서 사용한 데이터는 HR 스키마이고, 오라클 설치시 생성할 수 있는 기본 스키마 입니다>
# method 사용 예시 코드
declare
type tab_no is table of varchar2(100)
index by pls_integer;
v_tab_no tab_no;
v_total number;
begin
v_tab_no(1):='khaled';
v_tab_no(2):='ahmed';
v_tab_no(3):='jad';
v_tab_no(6):='nader';
v_tab_no(5):='joan';
for i in 1..10
loop
if v_tab_no.exists(i) then
dbms_output.put_line('the element '||i||' is exist in the array and='||v_tab_no(i));
else
dbms_output.put_line('the element '||i||' is not exist in the array');
end if;
end loop;
v_total:=v_tab_no.count;
dbms_output.put_line('the total elements in the array= '||v_total);
dbms_output.put_line('the first element INDEX in the array= '||v_tab_no.first);
dbms_output.put_line('the last element INDEX in the array= '||v_tab_no.last);
dbms_output.put_line('the NEXT element INDEX BEFORE INDEX 3 is '||v_tab_no.prior(3));
dbms_output.put_line('the NEXT element INDEX AFTER INDEX 3 is '||v_tab_no.NEXT(3));
end;
/*
the element 1 is exist in the array and=khaled
the element 2 is exist in the array and=ahmed
the element 3 is exist in the array and=jad
the element 4 is not exist in the array
the element 5 is exist in the array and=joan
the element 6 is exist in the array and=nader
the element 7 is not exist in the array
the element 8 is not exist in the array
the element 9 is not exist in the array
the element 10 is not exist in the array
the total elements in the array= 5
the first element INDEX in the array= 1
the last element INDEX in the array= 6
the NEXT element INDEX BEFORE INDEX 3 is 2
the NEXT element INDEX AFTER INDEX 3 is 5
*/
'Database > PLSQL' 카테고리의 다른 글
019 - [Oracle PL/SQL] Collections - Nested tables (0) | 2024.02.14 |
---|---|
018 - [Oracle PL/SQL] Collections - Index by Table of records (0) | 2024.02.14 |
016 - [Oracle PL/SQL] Collections - Index by tables(Associative arrays) (0) | 2024.02.14 |
015 - [Oracle PL/SQL] Records - Nested Records (0) | 2024.02.14 |
014 - [Oracle PL/SQL] Records - %rowtype (0) | 2024.02.14 |