Forum Stats

  • 3,827,397 Users
  • 2,260,770 Discussions
  • 7,897,225 Comments

Discussions

Generating a Unique Identifier in Table Column

MAFinanceDev-Oracle
MAFinanceDev-Oracle Member Posts: 13
edited Mar 31, 2015 2:15PM in APEX Discussions

I am trying to have APEX auto-generate a unique id (something like a UUID) in a column I have in a table.  I believe I have to use a trigger to do this, but as I try to create the trigger, I receive this error: Unable to Creat Trigger - ORA-24344: Success with compilation error

This is the code I'm using.  My table name is RECRET_MASTER and the name of the column I'm trying to have APEX generate a UUID is named UNIQUE_ID.

create or replace trigger "RECRET_MASTER_T1"

BEFORE

insert or update or delete on "RECRET_MASTER"

for each row

begin

insert NEWID ( )

end;

Any help would be greatly appreciated!  Thanks!

Tagged:

Answers

  • TexasApexDeveloper
    TexasApexDeveloper Member Posts: 7,932 Gold Crown
    edited Mar 31, 2015 1:55PM

    You need to provide more information.. What is the primary key of the table involved??

    Example below is on the emp table, the primary key of the table is emp_id

    create or replace trigger "EMP_T1"

    BEFORE

    insert or update or delete on "EMP"

    for each row

    begin

      :NEW.EmpI_D := <span class="pln">sys_guid</span><span class="pun">();</span><span class="pln"></span>

    end;

    This will generate a unique id for the emp table, based upon the system guid generator.

    If you need id's that are semi-sequential you can look at using a sequence to generate id's : Oracle/PLSQL: Sequences (autonumber)

    Thank you,

    Tony Miller
    LuvMuffin Software
    Ruckersville, VA

  • MAFinanceDev-Oracle
    MAFinanceDev-Oracle Member Posts: 13
    edited Mar 31, 2015 2:15PM

    Hi Tony,

    Thanks for the guidance.  The primary key of the table is the column UNIQUE_ID (the column I'm trying to create a unique ID for).  I also don't need id's that are sequential.

This discussion has been closed.