Oracle FOR Loop VARRAY Tutorial

In Oracle, you can use a FOR loop to iterate through a fixed collection. Here is an example:

DECLARE
  TYPE name_list IS VARRAY(3) OF VARCHAR2(20);
  names name_list := name_list('Alice', 'Bob', 'Charlie');
BEGIN
  FOR i IN 1..names.COUNT LOOP
    DBMS_OUTPUT.PUT_LINE('Name: ' || names(i));
  END LOOP;
END;

In the example above, we defined a fixed set name_list containing 3 string elements. We then used a FOR loop to iterate through the set and output the value of each element. The output is as follows:

Name: Alice
Name: Bob
Name: Charlie
bannerAds