Enumeration types in PL/SQL?
In the book Oracle PL/SQL for DBAs the definition of the type BOOLEAN
is shown:
SELECT text
FROM all_source
WHERE owner = 'SYS'
AND type = 'PACKAGE'
AND name = 'STANDARD'
AND line <5
/
TEXT
-------------------------------------------------------------
package STANDARD AUTHID CURRENT_USER is
/********** Types and subtypes, do not reorder **********/
type BOOLEAN is (FALSE, TRUE);
4 rows selected.
Have you seen that kind of type definition before? I did, it looks like a Delphi enumeration type when you replace the is
with =
. Let's define our own type.
create package TRAFFIC is
type LIGHT_T is (RED, YELLOW, GREEN);
end;
/
Warning: Package created with compilation errors.
SHOW ERR
LINE/COL TEXT
-------------------------------------------------------------
2,19 PLS-00505: User Defined Types may only be defined
as PLSQL Tables or Records
2,3 PL/SQL: Declaration ignored
2 rows selected
Perhaps this is an enhancement request for Oracle 11g release 2?
2 comments:
Hmmm...
TYPE rec_enum IS RECORD
(
yellow number := 1,
red number := 2
);
g_color REC_ENUM;
x := g_color.yellow;
not 100% enum but close?
Cool!
Post a Comment