Introduction / Issue
One of the common issues encountered while developing Oracle APEX applications is duplicate form submission. Users may unintentionally click the Save button multiple times due to slow network response or delayed processing. This results in duplicate records being inserted into the database, leading to inconsistent data and additional manual effort to clean up duplicate entries.
Why we need to do / Cause of the issue
Duplicate submissions generally occur when:
- Users click the Save button repeatedly before the page finishes processing.
- Network latency causes a delay, making users think the application is not responding.
- Database validations are missing or insufficient.
- The application does not prevent multiple requests from being processed simultaneously.
The impact includes:
- Duplicate database records.
- Incorrect reports and dashboards.
- Additional validation logic in downstream processes.
- Poor user experience and reduced confidence in the application.
How do we solve
A combination of front-end and back-end validations provides the best solution.
Step 1: Disable the Save button after the first click
Create a Dynamic Action on the Save button.
Event
- Click
True Action
- Execute JavaScript Code
this.triggeringElement.disabled = true;this.triggeringElement.innerText = “Processing…”;
This prevents multiple clicks while the page request is being processed.
Step 2: Add database validation
Create a unique constraint whenever possible.
Example:
ALTER TABLE EMPLOYEE_DETAILSADD CONSTRAINT UK_EMPLOYEEUNIQUE (EMP_ID);
If duplicate data is attempted, Oracle automatically prevents insertion.
Step 3: Perform a duplicate check before insert
DECLARE
l_count NUMBER;BEGIN
SELECT COUNT(*)
INTO l_count
FROM employee_details
WHERE emp_id = :P10_EMP_ID;
IF l_count > 0 THEN
raise_application_error(-20001,
‘Employee already exists.’);
END IF;END;
Real-Time Scenario
While developing an approval application, users frequently clicked the Submit button multiple times because the approval process required several seconds to complete.
By disabling the button immediately after the first click and introducing database validation, duplicate approvals were completely eliminated.
Conclusion
Preventing duplicate submissions improves data integrity and user confidence. Combining UI-level prevention with database validation creates a reliable and scalable solution. Implementing these checks early in development significantly reduces production issues and minimizes manual data correction efforts