·  PLSQL – Syntax – Collections – Hashtable

 

- Info:

  - This tutorial shows how to use Hashtables in JAVA.

  - Hastable is structure contining key-value pairs.

  - Hashtable can't contain duplicate keys, meaning that each key can map to at most one value.

  - In PL/SQL hashtable is created first by defining data types for values and keys.

 

- Example:

  - Create "PL/SQL Application" Test.sql.

 

    Test.sql

    declare

      type table1 is table of VARCHAR2(30) index by binary_integer;

      people table1;

    begin

      people(-10) := 'John';

      people(0)   := 'Jill';

    

      dbms_output.put_line(people(-10));

    end;

 

    Test.sql

    set serveroutput on

        

    declare

      type table1 is table of varchar2(30) index by varchar2(30);

      people table1;

    begin

      people('a') := 'John';

      people('b') := 'Jill';

    

      dbms_output.put_line(people('b'));

    end;