Interactive Grid: Prevent modify/delete record based on a specific column value
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 :
- Create new Interactive Grid page :
- Change Source type from Table/View to SQL Query :
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
isPRESIDENT
thennull
, this mean that row cannot be modified or deleted, and elseUD
TheU
meansUPDATE
andD
isDELETE
. So, whenJOB
notPRESIDENT
, this row can be updated and deleted. We can useUD
both or one of them, if we want the row be updatable we can writeU
only, and same thing with delete, we writeD
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
Change "AROC" column Type to Hidden :
-
From Interactive Grid attributes tab, change
Allowed Row Operations Column
=AROC
:
- 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
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