简体   繁体   中英

Insert value into 2 tables on button click on Oracle Application Express

So basically In my database I have a table that stores applications for jobs. These applications have a status that the user will be able to change from a drop down menu to for example invited for interview or application successful. I also have a table that needs to store when the status changes for each application and what it was changed to. The way I want to do this is that I have a form on Oracle Application Express that shows someones applications. They can then click an edit button to change the status of it. When the submit button is pressed I then want it to update the status in the application table but also create a new entry in the history table with the value the status was changed to along with the date they changed it. Would I use a trigger for this or is there another way of going about it on Oracle Application Express. Any help with this would be much appreciated.

You can do either. Which is appropriate depends on your situation.

  1. If the history table is merely a journal table that records all changes to the application table, I'd be comfortable with a simple trigger on the application table that inserts into the history table. However, you need to check that triggers are allowed in your environment (some DBAs don't like them). The downside is that triggers can be disabled - which would mean your history table would not be updated, and your application won't realise it's not working - users will get no errors. The advantage is that the history table will be maintained regardless of which application is updating the application table - whether Apex or some other client.

  2. You can have one or more PL/SQL processes that run when the page is submitted, and you can put arbitrary PL/SQL in them - eg an update of the application status, followed by an insert into the history table. The advantage of this is that the code will either run successfully, or fail with an error, so you know the history will be in-sync with the application table. The disadvantage of this is that the logic is coded in your front-end code, as it were; if your company decides to write another interface that updates the application table, the history might not be inserted (or not inserted in the same way).

  3. Write a wrapper procedure for the application status change, which does both of these actions; and call this procedure from your Apex PL/SQL process. This way the procedure can be re-used by other systems (if they're ever needed).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM