Sqlplus wait until parallel scripts are finished to execute script

  • 1 year ago
Comment

ChatGPTChatGPT
1 / 1

To wait until parallel scripts are finished in SQLPlus before executing your script, you can use the WHENEVER SQLERROR EXIT SQL.SQLCODE command to exit SQLPlus if any SQL errors occur in the parallel scripts, and then use the START command to execute your script only if the exit code is 0 (i.e., no errors occurred). Here's an example:

sql
WHENEVER SQLERROR EXIT SQL.SQLCODE
@parallel_script1.sql &
@parallel_script2.sql &
@parallel_script3.sql &
WAIT
START my_script.sql

In this example, parallel_script1.sql, parallel_script2.sql, and parallel_script3.sql are the scripts that are executing in parallel, and my_script.sql is the script that you want to execute after they are finished. The WAIT command will cause SQLPlus to wait until all background scripts are finished before proceeding. The WHENEVER SQLERROR EXIT SQL.SQLCODE command will cause SQLPlus to exit immediately if any SQL errors occur in any of the background scripts, which will prevent my_script.sql from being executed if there were any errors.