1 Reply Latest reply on Jan 15, 2014 9:08 PM by Mike Kutz

    Using Default in table Definition


      I am on APEX 4.2.4 and creating a Form page based on existing table. The table currently uses a default for creating the primary key:



             ( PK_ID             RAW(16) default sys_guid()

                                              CONSTRAINT pk_page

                                      PRIMARY KEY

                                         USING INDEX TABLESPACE psods_index

                                      STORAGE (INITIAL 4096

                                          NEXT    4096

                                          PCTINCREASE 0)



      When I go thru the APEX form create wizard and get to the point where it is asking about how to derive the Primary Key, none of the 3 options seem to be what I want (since the DB should be handling this with the 'default' option in my column. If I skip and try to create a record in the APEX page, it yells at me because the PK_ID doesn't have a value. I know I can create a function/procedure to handle this, but is there a better way?

        • 1. Re: Using Default in table Definition
          Mike Kutz

          You want "trigger".

          Treat it like a virtual column.

          ie you need to disable the Automatic DML from touching that column.

          It looks like this guy got the virtual column to work:  help is greatly needed with page processing in APEX


          I'm not sure if it is even possible to tell the "Automatic DML" to not touch the PK column.

          (I don't use "Automatic DML" because all of my DMLs are hidden in packages.)


          If you decide to go the DIY DML route, don't forget that you can use the RETURNING INTO clause to populate the hidden/display-only item type that hold the Primary Key


          insert into emp (ename)
          values ( :P3_ENAME)
          returning EMPNO into :P3_EMPNO;