'How To Generate A Unique ID On A Field In Oracle Apex When Tab/Enter Button Is Pressed?

I am trying to generate a unique ID on Oracle Apex Forms field while Enter/Tab button is pressed like we do in Oracle Forms using the Key-Next-Item And Post-Change triggers on a field.



Solution 1:[1]

This is not Forms, this is Apex.

Basically, you shouldn't allow users to modify such an item (keep it hidden or display only).

  • In Apex, we usually create a process which sets the primary key item's value, such as

    :P1_PK_ITEM := NVL(:P1_PK_ITEM, sequence_name.nextval);
    
  • Or, set that item's default value to fetch sequence's next value.

  • Or, create a database trigger which will populate column value before insert.

  • Or, if your database version is high enough (12c and later), create an identity column.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Littlefoot