{"id":2976,"date":"2019-08-27T01:41:52","date_gmt":"2019-08-27T08:41:52","guid":{"rendered":"https:\/\/oracletutorial.com\/?page_id=2976"},"modified":"2025-06-01T07:20:52","modified_gmt":"2025-06-01T14:20:52","slug":"plsql-varray","status":"publish","type":"page","link":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/","title":{"rendered":"PL\/SQL VARRAY"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn about the PL\/SQL <code>VARRAY<\/code> and how to manipulate elements of a <code>VARRAY<\/code> effectively.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-plsql-varray'>Introduction to PL\/SQL VARRAY <a href=\"#introduction-to-plsql-varray\" class=\"anchor\" id=\"introduction-to-plsql-varray\" title=\"Anchor for Introduction to PL\/SQL VARRAY\">#<\/a><\/h2>\n\n\n\n<p><code>VARRAY<\/code> stands for the variable-sized array. A <code>VARRAY<\/code> is single-dimensional collections of elements with the same data type. <\/p>\n\n\n\n<p>Unlike an <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-associative-array\/\">associative array<\/a> and <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-nested-tables\/\">nested table<\/a>, a <code>VARRAY<\/code> always has a fixed number of elements (bounded) and never has gaps between the elements (not sparse).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='declare-a-varray-type'>Declare a VARRAY type <a href=\"#declare-a-varray-type\" class=\"anchor\" id=\"declare-a-varray-type\" title=\"Anchor for Declare a VARRAY type\">#<\/a><\/h2>\n\n\n\n<p>To declare a <code>VARRAY<\/code> type, you use this syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">TYPE type_name IS VARRAY(max_elements)\n    OF element_type &#91;NOT NULL];<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this declaration:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>type_name<\/code> is the type of the <code>VARRAY<\/code>.<\/li>\n\n\n\n<li><code>max_elements<\/code> is the maximum number of elements allowed in the <code>VARRAY<\/code>.<\/li>\n\n\n\n<li><code>NOT NULL<\/code> specifies that the element of the <code>VARRAY<\/code> of that type cannot have <code>NULL<\/code> elements. Note that a <code>VARRAY<\/code> variable can be null, or uninitialized.<\/li>\n\n\n\n<li><code>element_type<\/code> is the type of elements of the <code>VARRAY<\/code> type&#8217;s variable.<\/li>\n<\/ul>\n\n\n\n<p>To create a <code>VARRAY<\/code> type which is accessible globally in the database, not just in your PL\/SQL code, you use the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">CREATE<\/span> &#91;<span class=\"hljs-keyword\">OR<\/span> <span class=\"hljs-keyword\">REPLACE<\/span> ] <span class=\"hljs-keyword\">TYPE<\/span> type_name <span class=\"hljs-keyword\">AS<\/span> | <span class=\"hljs-keyword\">IS<\/span>\n    <span class=\"hljs-keyword\">VARRAY<\/span>(max_elements) <span class=\"hljs-keyword\">OF<\/span> element_type &#91;<span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>];<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this declaration, the <code>OR REPLACE<\/code> modifies existing type while keeping all existing grants of privileges.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='declare-and-initialize-varray-variables'>Declare and initialize VARRAY variables <a href=\"#declare-and-initialize-varray-variables\" class=\"anchor\" id=\"declare-and-initialize-varray-variables\" title=\"Anchor for Declare and initialize VARRAY variables\">#<\/a><\/h2>\n\n\n\n<p>Once you created your own <code>VARRAY<\/code> type, you can declare a <code>VARRAY<\/code> instance of that type by referencing the <code>VARRAY<\/code> type. <\/p>\n\n\n\n<p>Here&#8217;s the basic syntax for <code>VARRAY<\/code> declaration:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name type_name &#91;:= type_name(...)];<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>varray_name<\/code> is the name of the <code>VARRAY<\/code>.<\/li>\n\n\n\n<li>The <code>type_name<\/code> is the <code>VARRAY<\/code> type.<\/li>\n\n\n\n<li>The <code>type_name(...)<\/code> is the constructor of the <code>VARRAY<\/code> type, which accepts a comma-separated list of elements as arguments. It has the same name as the <code>VARRAY<\/code> type.<\/li>\n<\/ul>\n\n\n\n<p>Note that before using a <code>VARRAY<\/code> variable, you must initialize it. Otherwise, you will receive the following error:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">ORA-06531: reference to uninitialized collection<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To initialize a <code>VARRAY<\/code> variable to an empty collection (zero elements), you use the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name type_name := type_name();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you want to specify elements for the <code>VARRAY<\/code> variable while initializing it, you can use this syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name type_name := type_name(element1, element2, ...);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='accessing-array-elements'>Accessing array elements <a href=\"#accessing-array-elements\" class=\"anchor\" id=\"accessing-array-elements\" title=\"Anchor for Accessing array elements\">#<\/a><\/h2>\n\n\n\n<p>To access an array element you use the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name(n);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p><code>n<\/code> is the index of the element, which begins with 1 and ends with the <code>max_elements<\/code> the maximum number of elements defined in the <code>VARRAY<\/code> type.<\/p>\n\n\n\n<p>If <code>n<\/code> is not in the range <code>(1, max_elements)<\/code>, PL\/SQL <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise\/\">raises<\/a> the <code>SUBSCRIPT_BEYOND_COUNT<\/code> error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='plsql-varray-examples'>PL\/SQL VARRAY examples <a href=\"#plsql-varray-examples\" class=\"anchor\" id=\"plsql-varray-examples\" title=\"Anchor for PL\/SQL VARRAY examples\">#<\/a><\/h2>\n\n\n\n<p>Let&#8217;s take some examples of using <code>VARRAY<\/code> variables.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='basic-plsql-varray-example'>Basic PL\/SQL VARRAY example <a href=\"#basic-plsql-varray-example\" class=\"anchor\" id=\"basic-plsql-varray-example\" title=\"Anchor for Basic PL\/SQL VARRAY example\">#<\/a><\/h3>\n\n\n\n<p>The following block illustrates a simple example of using <code>VARRAY<\/code> variables:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    <span class=\"hljs-keyword\">TYPE<\/span> t_name_type <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-keyword\">VARRAY<\/span>(<span class=\"hljs-number\">2<\/span>) \n        <span class=\"hljs-keyword\">OF<\/span> <span class=\"hljs-built_in\">VARCHAR2<\/span>(<span class=\"hljs-number\">20<\/span>) <span class=\"hljs-keyword\">NOT<\/span> <span class=\"hljs-literal\">NULL<\/span>;\n    t_names t_name_type  := t_name_type('John','Jane');\n    t_enames t_name_type := t_name_type();\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- initialize to an empty array<\/span>\n    dbms_output.put_line(<span class=\"hljs-string\">\"The number of elements in t_enames \"<\/span> || t_enames.COUNT);\n    \n    <span class=\"hljs-comment\">-- initialize to an array of a elements <\/span>\n    dbms_output.put_line(\"The number of elements in t_names \" || t_names.COUNT);\n<span class=\"hljs-keyword\">END<\/span>;\n\/\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example:<\/p>\n\n\n\n<p>First, declare a <code>VARRAY<\/code> of <code>VARCHAR(2)<\/code> with two elements:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">TYPE t_name_type IS \n    VARRAY(2) OF VARCHAR2(20) NOT NULL;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Next, declare a <code>VARRAY<\/code> variable and initialize it to a <code>VARRAY<\/code> of two elements:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">t_names t_name_type  := t_name_type('John','Jane');<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Then, declare another <code>VARRAY<\/code> variable and initialize it to an empty array:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">t_enames t_name_type := t_name_type();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>After that, use the <code>COUNT<\/code> method to get the number of elements in the <code>VARRAY<\/code> <code>t_enames<\/code> and display it.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">dbms_output.put_line(\"The number of elements in t_enames \" || t_enames.COUNT);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, use the same <code>COUNT<\/code> method to get the number of elements in the <code>VARRAY<\/code> <code>t_names<\/code> and print it out.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">dbms_output.put_line(\"The number of elements in t_names \" || t_names.COUNT);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Note that you can assign a <code>VARRAY<\/code> to another using the following syntax:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name := another_varray_name;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>For example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">t_enames := t_names;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>PL\/SQL copies all members of <code>t_names<\/code> to <code>t_enames<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='plsql-varray-of-records-example'>PL\/SQL VARRAY of records example <a href=\"#plsql-varray-of-records-example\" class=\"anchor\" id=\"plsql-varray-of-records-example\" title=\"Anchor for PL\/SQL VARRAY of records example\">#<\/a><\/h3>\n\n\n\n<p>See the following example:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    <span class=\"hljs-keyword\">TYPE<\/span> r_customer_type <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-built_in\">RECORD<\/span>(\n        customer_name customers.NAME%<span class=\"hljs-keyword\">TYPE<\/span>,\n        credit_limit customers.credit_limit%<span class=\"hljs-keyword\">TYPE<\/span>\n    ); \n    \n    TYPE t_customer_type IS VARRAY(2) \n        OF r_customer_type;\n\n    t_customers t_customer_type := t_customer_type();\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    t_customers.EXTEND;\n    t_customers(t_customers.LAST).customer_name := 'ABC Corp';\n    t_customers(t_customers.LAST).credit_limit  := 10000;\n    \n    t_customers.EXTEND;\n    t_customers(t_customers.LAST).customer_name := 'XYZ Inc';\n    t_customers(t_customers.LAST).credit_limit  := 20000;\n    \n    dbms_output.put_line('The number of customers is ' || t_customers.COUNT);\n<span class=\"hljs-keyword\">END<\/span>;\n\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>First, define a <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-record\/\">record<\/a> type that includes two fields customer name and credit limit:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">TYPE r_customer_type IS RECORD(\n    customer_name customers.name%TYPE,\n    credit_limit customers.credit_limit%TYPE\n); <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Next, declare a <code>VARRAY<\/code> type of the record <code>r_customer_type<\/code> with the size of two:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">TYPE t_customer_type IS VARRAY(2) \n    OF r_customer_type;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Then, declare a <code>VARRAY<\/code> variable of the <code>VARRAY<\/code> type <code>t_customer_type<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">t_customers t_customer_type := t_customer_type();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>After that, use the <code>EXTEND<\/code> method to add an instance to <code>t_customers<\/code> and the <code>LAST<\/code> method to append an element at the end of the <code>VARRAY<\/code> <code>t_customers<\/code><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">t_customers.EXTEND;\nt_customers(t_customers.LAST).customer_name := 'ABC Corp';\nt_customers(t_customers.LAST).credit_limit  := 10000;\n    \nt_customers.EXTEND;\nt_customers(t_customers.LAST).customer_name := 'XYZ Inc';\nt_customers(t_customers.LAST).credit_limit  := 20000;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, use the <code>COUNT<\/code> method to get the number of elements in the array:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">dbms_output.put_line('The number of customers is ' || t_customers.COUNT);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here is the output of the block:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-22\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">The number of customers is 2<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-22\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='adding-elements-to-varray-from-a-cursor-example'>Adding elements to VARRAY from a cursor example <a href=\"#adding-elements-to-varray-from-a-cursor-example\" class=\"anchor\" id=\"adding-elements-to-varray-from-a-cursor-example\" title=\"Anchor for Adding elements to VARRAY from a cursor example\">#<\/a><\/h3>\n\n\n\n<p>The following example uses a <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-cursor\/\">cursor<\/a> to retrieve five customers who have the highest credits from the <code>customers<\/code> table and add data to a <code>VARRAY<\/code>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"144\" height=\"145\" src=\"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2017\/07\/customers-table.png\" alt=\"customers table\" class=\"wp-image-298\"\/><\/figure>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-23\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    <span class=\"hljs-keyword\">TYPE<\/span> r_customer_type <span class=\"hljs-keyword\">IS<\/span> <span class=\"hljs-built_in\">RECORD<\/span>(\n        customer_name customers.name%<span class=\"hljs-keyword\">TYPE<\/span>,\n        credit_limit customers.credit_limit%<span class=\"hljs-keyword\">TYPE<\/span>\n    ); \n\n    TYPE t_customer_type IS VARRAY(5) \n        OF r_customer_type;\n    \n    t_customers t_customer_type := t_customer_type();\n\n    CURSOR c_customer IS \n        <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">NAME<\/span>, credit_limit \n        <span class=\"hljs-keyword\">FROM<\/span> customers \n        <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> credit_limit <span class=\"hljs-keyword\">DESC<\/span> \n        <span class=\"hljs-keyword\">FETCH<\/span> <span class=\"hljs-keyword\">FIRST<\/span> <span class=\"hljs-number\">5<\/span> <span class=\"hljs-keyword\">ROWS<\/span> <span class=\"hljs-keyword\">ONLY<\/span>;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- fetch data from a cursor<\/span>\n    <span class=\"hljs-keyword\">FOR<\/span> r_customer <span class=\"hljs-keyword\">IN<\/span> c_customer <span class=\"hljs-keyword\">LOOP<\/span>\n        t_customers.EXTEND;\n        t_customers(t_customers.LAST).customer_name := r_customer.name;\n        t_customers(t_customers.LAST).credit_limit  := r_customer.credit_limit;\n    <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">LOOP<\/span>;\n\n    <span class=\"hljs-comment\">-- show all customers<\/span>\n    FOR l_index IN t_customers .FIRST..t_customers.LAST \n    LOOP\n        dbms_output.put_line(\n            'The customer ' ||\n            t_customers(l_index).customer_name ||\n            ' has a credit of ' ||\n            t_customers(l_index).credit_limit\n        );\n    <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">LOOP<\/span>;\n\n<span class=\"hljs-keyword\">END<\/span>;\n\/\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-23\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example:<\/p>\n\n\n\n<p>First, declare a record type, a <code>VARRAY<\/code> type of the record with 5 elements, and a <code>VARRAY<\/code> variable of that <code>VARRAY<\/code> type:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-24\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">TYPE r_customer_type IS RECORD(\n    customer_name customers.name%TYPE,\n    credit_limit customers.credit_limit%TYPE\n); \n\nTYPE t_customer_type IS VARRAY(5) \n    OF r_customer_type;\n    \nt_customers t_customer_type := t_customer_type();<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-24\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, declare a cursor that retrieves 5 customers with the highest credits:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-25\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">CURSOR c_customer IS \n    <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">name<\/span>, credit_limit \n    <span class=\"hljs-keyword\">FROM<\/span> customers \n    <span class=\"hljs-keyword\">ORDER<\/span> <span class=\"hljs-keyword\">BY<\/span> credit_limit <span class=\"hljs-keyword\">DESC<\/span> \n    <span class=\"hljs-keyword\">FETCH<\/span> <span class=\"hljs-keyword\">FIRST<\/span> <span class=\"hljs-number\">5<\/span> <span class=\"hljs-keyword\">ROWS<\/span> <span class=\"hljs-keyword\">ONLY<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-25\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Third, process the cursor and append each element to the <code>VARRAY<\/code> <code>t_customers<\/code>:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-26\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">FOR r_customer IN c_customer LOOP\n    t_customers.EXTEND;\n    t_customers(t_customers.LAST).customer_name := r_customer.name;\n    t_customers(t_customers.LAST).credit_limit  := r_customer.credit_limit;\n<span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">LOOP<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-26\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, iterate over the elements of the <code>VARRAY<\/code> <code>t_customers<\/code> and print out the customer name and credit:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-27\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">FOR l_index IN t_customers .FIRST..t_customers.LAST \n    LOOP\n        dbms_output.put_line(\n            'The customer ' ||\n            t_customers(l_index).customer_name ||\n            ' has a credit of ' ||\n            t_customers(l_index).credit_limit\n        );\n    <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">LOOP<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-27\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here is the output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-28\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">The customer General Mills has a credit of 179916.92\nThe customer NextEra Energy has a credit of 141953.76\nThe customer Southern has a credit of 127665.21\nThe customer Jabil Circuit has a credit of 113340.75\nThe customer Progressive has a credit of 94989.78\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-28\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='deleting-elements'>Deleting elements <a href=\"#deleting-elements\" class=\"anchor\" id=\"deleting-elements\" title=\"Anchor for Deleting elements\">#<\/a><\/h2>\n\n\n\n<p>To delete all elements of a <code>VARRAY<\/code>, you use the <code>DELETE<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-29\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name.DELETE;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-29\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To remove one element from the end of a <code>VARRAY<\/code>, you use the <code>TRIM<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-30\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name.TRIM;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-30\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To remove n elements from the end of a <code>VARRAY<\/code>, you use the <code>TRIM(n)<\/code> method:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-31\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">varray_name.TRIM(n)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-31\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this tutorial, you have learned about PL\/SQL <code>VARRAY<\/code> and how to manipulate elements of a <code>VARRAY<\/code> effectively.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2976\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/\"\n\t\t\t\tdata-post-title=\"PL\/SQL VARRAY\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2976\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/\"\n\t\t\t\tdata-post-title=\"PL\/SQL VARRAY\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn about the PL\/SQL VARRAY and how to manipulate elements of a VARRAY effectively.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1418,"menu_order":44,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2976","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>PL\/SQL VARRAY<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn about the PL\/SQL VARRAY and how to manipulate elements of a VARRAY effectively.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PL\/SQL VARRAY\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about the PL\/SQL VARRAY and how to manipulate elements of a VARRAY effectively.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/\" \/>\n<meta property=\"og:site_name\" content=\"Oracle Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-01T14:20:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2017\/07\/customers-table.png\" \/>\n\t<meta property=\"og:image:width\" content=\"144\" \/>\n\t<meta property=\"og:image:height\" content=\"145\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/\",\"name\":\"PL\\\/SQL VARRAY\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.oracletutorial.com\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/customers-table.png\",\"datePublished\":\"2019-08-27T08:41:52+00:00\",\"dateModified\":\"2025-06-01T14:20:52+00:00\",\"description\":\"In this tutorial, you will learn about the PL\\\/SQL VARRAY and how to manipulate elements of a VARRAY effectively.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/customers-table.png\",\"contentUrl\":\"https:\\\/\\\/www.oracletutorial.com\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/customers-table.png\",\"width\":144,\"height\":145,\"caption\":\"customers table\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-varray\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.oracletutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PL\\\/SQL Tutorial\",\"item\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"PL\\\/SQL VARRAY\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/\",\"name\":\"Oracle Tutorial\",\"description\":\"Oracle Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.oracletutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PL\/SQL VARRAY","description":"In this tutorial, you will learn about the PL\/SQL VARRAY and how to manipulate elements of a VARRAY effectively.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/","og_locale":"en_US","og_type":"article","og_title":"PL\/SQL VARRAY","og_description":"In this tutorial, you will learn about the PL\/SQL VARRAY and how to manipulate elements of a VARRAY effectively.","og_url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/","og_site_name":"Oracle Tutorial","article_modified_time":"2025-06-01T14:20:52+00:00","og_image":[{"width":144,"height":145,"url":"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2017\/07\/customers-table.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/","url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/","name":"PL\/SQL VARRAY","isPartOf":{"@id":"https:\/\/www.oracletutorial.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/#primaryimage"},"image":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/#primaryimage"},"thumbnailUrl":"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2017\/07\/customers-table.png","datePublished":"2019-08-27T08:41:52+00:00","dateModified":"2025-06-01T14:20:52+00:00","description":"In this tutorial, you will learn about the PL\/SQL VARRAY and how to manipulate elements of a VARRAY effectively.","breadcrumb":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/#primaryimage","url":"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2017\/07\/customers-table.png","contentUrl":"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2017\/07\/customers-table.png","width":144,"height":145,"caption":"customers table"},{"@type":"BreadcrumbList","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-varray\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.oracletutorial.com\/"},{"@type":"ListItem","position":2,"name":"PL\/SQL Tutorial","item":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/"},{"@type":"ListItem","position":3,"name":"PL\/SQL VARRAY"}]},{"@type":"WebSite","@id":"https:\/\/www.oracletutorial.com\/#website","url":"https:\/\/www.oracletutorial.com\/","name":"Oracle Tutorial","description":"Oracle Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.oracletutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/2976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/comments?post=2976"}],"version-history":[{"count":0,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/2976\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/1418"}],"wp:attachment":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/media?parent=2976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}