A simple way to add a delete row function from a report in Oracle APEX

I had a requirement to add a delete button in an Interactive Report of Oracle APEX. I did some research online and found a few articles discussing on how to do this. But they are using java scripts and dynamic actions.

However, I wanted to see if there is a simpler way to do this. After giving it some more thought, I figured out something simple. Let me show you.

Assuming we had an Interactive Report as shown in the Figure below.



Now we add a column link. We can do this by adding an additional item in the query or using the Interactive Report Attributes. I'll use the first approach in this case. See screen shots below.





At this point, we have an additional column in the report (see screen shot below) but it doesn't do anything yet.



Now on to the solution.


Create a blank page and set it as a Modal Dialog.



Create a Region and set the Type as Static Content under Identification. Set the region's Text field under Source to "Would you like to perform this delete action?". Set the region's Template under Appearance to Blank with Attributes (No Grid).



Add a page item to the region and name it to PX_ID (where X is the page number). Set it to Hidden.



Add a Cancel button in the region and create a Cancel Dialog Dynamic Action to the Cancel button.



Add an OK button in the region.

Create a process with Type of PL/SQL Code. Select the button OK on When Button Pressed under Server-side Condition. Then in the PL/SQL Code under Source, enter the appropriate code to delete the record. In my case, I need to execute the following:
DELETE FROM my_table WHERE id = :PX_ID;



Create a process with Type of Close Dialog. Select the button OK on When Button Pressed under Server-side Condition.



Let's go back to the report page and edit the following properties for the DELETE_LINK column.

Under Link, set Target to Page in this application.

Under Page, select the modal page we just created.

Under Set Items, select the PX_ID (where X is the page number of modal page) for Name and PY_ID (where Y is the page number of report page).

Under Clear Cache, enter the page number of the modal page then click OK.




In the Link Text under Link, let's change this to a trash icon. Enter the following:
<span aria-hidden="true" class="fa fa-trash"></span>


Now all that's left to do is to run it.



That's it. Enjoy!

11 comments:

  1. i have implemented delete action through this way. nice and simple work is.\

    one issue is how to refresh classic/interactive report after delete action? pLEASE TELL

    Thanks in advance

    ReplyDelete
    Replies
    1. Hi. To refresh the report, we need to create a Dynamic Action with Event "Dialog Closed" and TRUE Action "Refresh". Then select the region you wish to refresh. In this case, the report region.

      Delete
  2. It doesent work for me...
    I use APEX 20.1
    everything just fine... but at the end it just cant refresh my (p5) page...
    can you please help???

    ReplyDelete
    Replies
    1. Hi. To refresh the report, we need to create a Dynamic Action with Event "Dialog Closed" and TRUE Action "Refresh". Then select the region you wish to refresh. In this case, the report region.

      Delete
  3. on which page should i create dynamic action? I cant choose refresh report region from dialog page.

    Please help!

    ReplyDelete
    Replies
    1. Should be the page with the report that needs refreshing.

      Delete
  4. Thanks a lot for sharing a valuable blog on oracle apex training. I was browsing through the internet looking for Oracle PPM Cloud and Oracle fusion applications and came across your blog. I am impressed by the information that you have on this blog. It shows how well you understand this subject, you can find more information about Oracle Apex by attending oracle apex courses online. You can learn about interview questions by visiting fusion Interview Questions

    ReplyDelete
  5. I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site. As a result of checking through the net and meeting techniques that were not productive, Same as your blog I found another one Oracle APEX .Actually I was looking for the same information on internet for Oracle APEX and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.

    ReplyDelete
  6. Firms to close three properties linked to Fonseca casino - Film
    The 검증 업체 directors' associations with Fonseca casino 사설 토토 자수 유니 88 will be 망고사이트 of the slots, such as blackjack 토토 사이트 추천 샤오 미 and roulette bj 사이트 table games, according to the Italian gambling

    ReplyDelete