Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add Enumeration Types to PL/SQL

jnicholas330Oct 8 2016 — edited Oct 8 2016

Pl/SQL has one predefined enumeration type, BOOLEAN, defined as 

type BOOLEAN is (FALSE, TRUE);

it would be nice to allow programmers to construct their own enumeration types. Right now programmers have to create constants to work around this:

l_failure constant pls_integer := -1;

l_success constant pls_integer := 0;

however, this could be more easily expressed as

type result is (failure,success);

PL/SQL already supports enumeration comparisons for BOOLEAN, e.g.

SQL> set serveroutput on;

SQL> begin

  2  if false < true then

  3   dbms_output.put_line('false is less than true');

  4  end if;

  5  end;

  6  /

false is less than true

PL/SQL procedure successfully completed.

SQL>

Comments
Post Details
Added on Oct 8 2016
9 comments
5,199 views