How to Prevent Duplicate Row Interactive Grid Oracle APEX
|
Preview gif |
Sometimes user wants to prevent duplicate row on that column where columns don't have a unique Id or Primary key Identification. On those cases here, I have provided a solution which will definitely help you.
- Create an editable Interactive Grid using the following query:
select ROWID,
EMPNO,
ENAME,
JOB,
DEPTNO
from EMP
|
SQL Query |
- Create validation on the column on which you want to prevent duplicate rows. Select validation type (PL/SQL Function returning Error text), copy and paste bellow PLSQL code:
declare
l_count number;
begin
if :APEX$ROW_STATUS ='C' then -- You can use 'C' OR 'I'
select count(1) into l_count FROM EMP where EMPNO=:EMPNO;
end if;
if l_count>=1 then
return 'Employee Code '||:EMPNO||' is duplicate';
end if;
end;
|
Validation |
Very good Vikas. keep posting kind of blogs.
ReplyDelete