Sunday, September 13, 2015

Custom Code for Tabular Forms (Part 1)

Over a year ago I wrote an article covering how to create a tabular form and then use custom PL/SQL to process the data rather than the automatic Apply MRU and Apply MRD processes. The demo showed how to do this in APEX 4.2. This article will re-introduce the topic but use APEX 5.0 instead.


Create new Tabular Form

  • Create page > Page type: Form > Tabular Form
  • Select the following options: 
    • Note: For simplicity/demo purposes, limiting to just the SAL and ENAME columns.
  • Primary Key: Select Primary Key Column(s) > Primary Key Column 1 > EMPNO
  • Run through the rest of the wizard.

Remove Automatic DML

Since custom code will be used to process the page, delete the automatic row processing process as shown below.


Create Process

Create a new process with the following settings (the Source is included below the image).

if :empno is null then
  -- code to insert emp
  null;
else
  update emp
  set
    ename = :ename,
    sal = :sal
  where empno = :empno;
end if;


Using the above technique you can now use a tabular form to call custom PL/SQL code rather than the automatic row processing.

The next article will cover how to modify data from multiple tables in the same Tabular Form.

7 comments:

  1. Martin, you deleted the ApplyMRD process without implementing a replacement Delete capability. Your code shows how to distinguish between insert and update, but how would you identify a delete request?

    ReplyDelete
  2. Good point. I'll write up a new post regarding the deletes soon.

    ReplyDelete
    Replies
    1. Have you ever done a write up regarding deletes?
      This article really helped make the whole custom processing for a tabular form so much easier. Thanks.

      Delete
    2. I haven't written one yet. Hopefully soon.

      Delete
  3. Thank you so much for this. After trying many other options that failed to work, I finally found your blog post which solved my issue instantly. Great post!

    ReplyDelete
  4. Thanks for your excellent post. It has been a great help.
    gsc

    ReplyDelete
  5. If you delete the MRU, and the form uses rowid as PK, deletes no longer work....set the MRU condition to never, and then the PK definition from it is still used.

    ReplyDelete