Skip to Main Content

SQL & PL/SQL

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!

PL SQL Trigger to write data to multiple tables

Matt StathopoulosFeb 29 2024 — edited Feb 29 2024

Hello,

I am having trouble creating an ‘after insert’ trigger that will write data from the new row to multiple tables.

I am working out of Oracle APEX 22.1.6. The requirement is to allow the user to upload an excel file that will update a main (calculation) table, and 3 relationship tables with the autogenerated calculation ID.

The process as of now is to update a ‘temp table’ (via data load definition) and have an after update trigger on that table to write to the 4 tables that actually need the update.

In the code, I have an exception to handle duplicate values on the main calculation table (duplicate values found via unique constraint on specific columns). In the exception block I am trying to run a query that will return the ID of the repeated metric so I can update the relationship tables with more mapping. I receive a “No data found error” when raising the exception. When commenting out the select query on line 19, there is no error. So, therefore, I believe the error stems from that select statement.

Here is the trigger code where the error happens:

Any ideas on how to fix this code?

Comments
Post Details
Added on Feb 29 2024
2 comments
661 views