associative array in pl sql

Solutions on MaxInterview for associative array in pl sql by the best coders in the world

showing results for - "associative array in pl sql"
Marci
02 Nov 2017
1
2        
3            
4        
5     DECLARE
6    -- declare an associative array type
7    TYPE t_capital_type 
8        IS TABLE OF VARCHAR2(100) 
9        INDEX BY VARCHAR2(50);
10    -- declare a variable of the t_capital_type
11    t_capital t_capital_type;
12    -- local variable
13    l_country VARCHAR2(50);
14BEGIN
15    
16    t_capital('USA')            := 'Washington, D.C.';
17    t_capital('United Kingdom') := 'London';
18    t_capital('Japan')          := 'Tokyo';
19    
20    l_country := t_capital.FIRST;
21    
22    WHILE l_country IS NOT NULL LOOP
23        dbms_output.put_line('The capital of ' || 
24            l_country || 
25            ' is ' || 
26            t_capital(l_country));
27        l_country := t_capital.NEXT(l_country);
28    END LOOP;
29END;
30/
31