Skip to Main Content

Oracle Database Discussions

Request for enum support in pl/sql

User_LFNWXOct 18 2022 — edited Oct 18 2022

Request for ability to define enum like structures in pl/sql. Currently there workarounds to do this like using oracle types and constructor functions. However would like to see a more user-friendly implementation of this.
Perhaps something that would allow for referencing the enum values w/o string/literal matching such as can be done with pl/sql constants and other languages. E.g.

for i in (select * from levels_table) loop
   if i.level_col = level.MEDIUM then ...

Java

public class Main {
  enum Level {
    LOW,
    MEDIUM,
    HIGH
  }

  public static void main(String[] args) {
    Level myVar = Level.MEDIUM; 
    System.out.println(myVar);
  }
}

C#

class Program
{
  enum Level
  {
    Low,
    Medium,
    High
  }
  static void Main(string[] args)
  {
    Level myVar = Level.Medium;
    Console.WriteLine(myVar);
  }
}

Related post:
https://community.oracle.com/tech/developers/discussion/4504763/request-for-enum-support-in-pl-sql

Comments
Post Details
Added on Oct 18 2022
1 comment
94 views