2 Replies Latest reply: May 27, 2012 7:04 AM by xarg-Xrc RSS

    Getting primary key of entry just created by submitting form

    xarg-Xrc
      Hi Guys,

      I have a form built in APEX based on a table. The PK is generated by sequence and the form values are saved by DML (insert).

      What I need to do is once I create a new entry with my from, I need to update a whole bunch of other tables with the new PK which I can easily do by creating a PL/SQL process after DML.



      However, I need the primary key generated by by the new entry (created by filling up the form + submit).

      One way around it is
      Select max(userid) from user
      to retrieve it but I am not sure if this is a good idea/practice.

      Any idea guys? Cheers.
        • 1. Re: Getting primary key of entry just created by submitting form
          VC
          taepodong wrote:
          Hi Guys,

          I have a form built in APEX based on a table. The PK is generated by sequence and the form values are saved by DML (insert).

          What I need to do is once I create a new entry with my from, I need to update a whole bunch of other tables with the new PK which I can easily do by creating a PL/SQL process after DML.



          However, I need the primary key generated by by the new entry (created by filling up the form + submit).

          One way around it is
          Select max(userid) from user
          to retrieve it but I am not sure if this is a good idea/practice.
          This will only give the maximum ID and not the currently generated ID
          Any idea guys? Cheers.
          Use this APEX feature
          Edit your page > Edit you DML process for the form > Enter you page item into Return Key Into Item (this returns the new pk value generated by this form)
          • 2. Re: Getting primary key of entry just created by submitting form
            xarg-Xrc
            Thanks VC. That's what I was looking for.