Interactive Grid: Prevent modify/delete record based on a specific column value

Hamza Al-abbasiHamza Al-abbasi
2 min read

In most cases we need some records in Interactive Grid NOT to be modified/deleted based on a specific column value.

In this post, I will explain how to do this using Allowed Row Operations Column attribute in Interactive Grid.

Assume that we have an Interactive Grid with source EMP table and we want to prevent modify/delete the records when JOB column value is PRESIDENT. To do this, follow the steps below :

  1. Create new Interactive Grid page :

  1. Change Source type from Table/View to SQL Query :

  1. Change SQL Query as following :

     select 
         empno,
         ename,
         job,
         mgr,
         hiredate,
         sal,
         comm,
         deptno,
         case when job = 'PRESIDENT' then null else 'UD' end as aroc
     from emp
    

    In the above SQL Query, we added a virtual column named "AROC". This column has a condition, when JOB is PRESIDENT then null, this mean that row cannot be modified or deleted, and else UD The U means UPDATE and D is DELETE. So, when JOB not PRESIDENT, this row can be updated and deleted. We can use UD both or one of them, if we want the row be updatable we can write U only, and same thing with delete, we write D only. If you want when condition is met that record can be editable, you can change the condition as following :

     case when job = 'PRESIDENT' then 'D' else 'UD' end as aroc
    
  2. Change "AROC" column Type to Hidden :

  3. From Interactive Grid attributes tab, change Allowed Row Operations Column = AROC :

  1. Save and run page.

You will realize that the record that condition is met is appear like this (with gray color) :

So that's means the above record (when JOB = PRESIDENT) cannot be modified or deleted.

Live demo :

https://apex.oracle.com/pls/apex/r/alabbasi/hamza-s-apex-blog-examples/prevent-records-modification

0
Subscribe to my newsletter

Read articles from Hamza Al-abbasi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Hamza Al-abbasi
Hamza Al-abbasi

Oracle APEX Developer in HorizonsTek