PL/SQL - Associative Arrays (Index-By Tables) - Table Of Indexed By - Map

Card Puncher Data Processing

About

An associative array (also called an index-by table) is a map structure (set of key-value pair) implemented with the “table of index by” keyword

Syntax

TYPE table_of_type IS TABLE OF VARCHAR2(30) ; -- default indexed by integer  -- List of Called a Nested table

Syntax

Characteristic

  • Each key is unique
  • The key can be either an integer or a string.

Example

set serveroutput on;
DECLARE
  TYPE filter_map_type IS TABLE OF VARCHAR2(30) INDEX BY VARCHAR2(30);
  filter_map filter_map_type;
  key_map VARCHAR2(30);
BEGIN

filter_map('Hello Key') := 'Hello Value';
filter_map('Hello Key 2') := 'Hello Value 2';
filter_map('Hello Key') := 'Hello Value 3';

key_map := filter_map.FIRST; 
WHILE key_map IS NOT NULL LOOP
   
   DBMS_OUTPUT.Put_Line('element(' || key_map || '): ' || filter_map(key_map));
   key_map := filter_map.NEXT(key_map);
   
END LOOP;
END;
/
PL/SQL procedure successfully completed.

element(Hello Key): Hello Value 3
element(Hello Key 2): Hello Value 2





Discover More
Card Puncher Data Processing
PL/SQL - (Nested) tables (Table Of without indexing)

A “table of” data type without the index-by clause is a list of elements (collection). For a table of indexed by, see Syntax...
Card Puncher Data Processing
PL/SQL - Collections (Datatype Table of, Varray of)

Many programming techniques use collection types. To support these techniques in database applications, PL/SQL provides three data types of collections: Associative arrays (formerly called “PL/SQL...
Card Puncher Data Processing
PL/SQL - Table Of Clause

A “table of” data type is a list of elements (collection) implementing: by default a list structure without the index-by clause. See bu can be used to implement a map structure with the index-by...



Share this page:
Follow us:
Task Runner