Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Inserstng nvl(max(column value), 0) +1 from table into pk column.

Eslam_ElbyalyFeb 9 2022 — edited Feb 9 2022

Oracle APEX 21.2.0.
I have an IG on DEPT table. And a process that runs before ARP process wth the followng code
select nvl(max(deptno), 0) + 1 into :deptno from dept;
when I try to add more than one row I got "Unique constraint violated" error. It does not make sense to me because when I click SAVE I am still in the same database session which means that insert statement fired and added one to the max deptno value so a new value should be retrieved with each row?
I know I can use a sequence but I need to know why this approach does not work?

Comments
Post Details
Added on Feb 9 2022
7 comments
652 views