How To Create an Array in PL/SQL?
Submitted by: AdministratorIf you want create an array data structure, you can use the collection type VARRAY. VARRAY stands for Variable Array. Here is a sample script on how to use VARRAY:
SQL> set serveroutput on;
SQL> DECLARE
2 TYPE list IS VARRAY(3) OF VARCHAR(16);
3 domain_list list;
4 BEGIN
5 domain_list := list('google','globalguideline','myspace');
6 DBMS_OUTPUT.PUT_LINE('Second domain: '
7 || domain_list(2));
8 END;
9 /
Second domain: globalguideline
As you can see, to define an array variable, you need to create your own array type, and use that type to define array variables.
Submitted by: Administrator
SQL> set serveroutput on;
SQL> DECLARE
2 TYPE list IS VARRAY(3) OF VARCHAR(16);
3 domain_list list;
4 BEGIN
5 domain_list := list('google','globalguideline','myspace');
6 DBMS_OUTPUT.PUT_LINE('Second domain: '
7 || domain_list(2));
8 END;
9 /
Second domain: globalguideline
As you can see, to define an array variable, you need to create your own array type, and use that type to define array variables.
Submitted by: Administrator
Read Online Oracle Database Job Interview Questions And Answers
Top Oracle Database Questions
☺ | How Run SQL*Plus Commands That Are Stored in a Local File? |
☺ | How Much Memory Your 10g XE Server Is Using? |
☺ | How To Run SQL*Plus Commands in SQL Developer? |
☺ | What Is the Relation of a User Account and a Schema? |
☺ | What Is Input Buffer in SQL*Plus? |
Top DB Oracle Categories
☺ | Oracle PL-SQL Interview Questions. |
☺ | Oracle DBA Interview Questions. |
☺ | Oracle D2K Interview Questions. |
☺ | OCI Interview Questions. |
☺ | Oracle RMAN Interview Questions. |