-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path7.3 varray.sql
41 lines (35 loc) · 1.33 KB
/
7.3 varray.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
DECLARE
TYPE e_list IS
VARRAY(6) OF VARCHAR2(30);
employees e_list;
BEGIN
-- Count function
dbms_output.put_line('Count : ' || chr(10));
employees := e_list('hamza', 'sajid', 'fred', 'alex');
employees.extend;
employees(5) := 'msa'; -- we can add new element to varray if we use extend to add new null element.
-- employees.delete(5); we cannot delete from varray
FOR i IN 1..employees.count() LOOP dbms_output.put_line(employees(i)); -- count of varray retunr only the number of values on it count always equal last in varray
END LOOP;
employees.extend;
dbms_output.put_line(chr(10)
|| 'last and first functions : '
|| employees.count()
|| chr(10));
-- Last and first functions
FOR i IN employees.first()..employees.last() LOOP dbms_output.put_line(employees(i));
END LOOP;
dbms_output.put_line(chr(10)
|| 'Exists function : '
|| chr(10));
-- Exists functions
FOR i IN 1..5 LOOP IF employees.EXISTS(i) THEN
dbms_output.put_line(employees(i));
END IF;
END LOOP;
dbms_output.put_line(chr(10)
|| 'limit function :'
|| chr(10));
-- Limit function
dbms_output.put_line(employees.limit());
END;