?
Solved

How to check whether insert was successful in a PL/SQL procedure?

Posted on 2014-12-27
1
Medium Priority
?
365 Views
Last Modified: 2014-12-27
Dear Experts,

I would like to run TRUNCATE TABLE statement in below code IF ONLY previous insert was successful. How can I implement this? It would be great if you offer me a piece of complemantary code.

BR


DECLARE
.......
BEGIN
.......
INSERT INTO MAIN_TABLE SELECT * FROM TEMP_TABLE;
COMMIT;
EXECUTE IMMEDIATE 'TRUNCATE TABLE TEMP_TABLE DROP STORAGE';
END;
0
Comment
Question by:GurcanK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 40519654
If your insert or the commit fails then you'll raise an exception and the block will end (or jump to an exception handler if you declare one) so, your truncate is already in the correct place to ensure it only executes after a successful insert and commit
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question