Link to home
Start Free TrialLog in
Avatar of GurcanK
GurcanK

asked on

PL/SQL Conditional Execution

Dear Experts,

I want to write a PL/SQL procedure such that: If a result of an Update statement is successful, then I'll delete a record from other table.

How can I implement this?

Best Regards
SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GurcanK
GurcanK

ASKER

It is something like:

loop <condition>

update table ta where ......;

delete table tx where ....

end loop

can it be like:

loop <condition>

update table ta where ......;

ıf no exception then delete table tx where ....

end loop
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Based on the other questions, I will say it again.

Get rid of the delete completely.  You are worrying about something  you don't need to.

In the case of a failure, truncate the temporary table and then repopulate it.  It is a temporary table being used for the updates.  No need to try to work around it.  Truncate and recreate removes the delete statement and the scan of deleted rows in the event of a restart (the blocks still need to be read as it will be a full table scan).
Seems I missed something...