onError

The "onError" property determines when to stop or continue the execution of all SQL statements. It is an optional string that defaults to "continue".

  • Possible values:
    • "stop"
      • Setting "onError" to "stop" causes the "runSqlStatements" action to stop executing SQL statements when it encounters an error. Stopping "runSqlStatements" on an error is useful when running subsequent steps that would cause problems or would consume server resources unnecessarily.
    • "continue"
      • Setting "onError" to "continue" causes the "runSqlStatements" action to continue executing SQL statements when it encounters an error. Continuing "runSqlStatements" on even when an error occurs is useful when you want to verify the viability of each specified statement, such as ensuring it uses the correct syntax and executes properly.
  • There are use cases in which use "onError" and "atEnd" together.
    • When prototyping code.
      • "onError": "continue ", "atEnd": "rollback" 
      • Use this sample when you want all statements to run and report errors, but you do not want to commit any changes. This is useful in development when you want to try out a number of SQL statements to check their syntax, performance, and proper execution and you do not yet want to commit changes because you are still developing the code. It is convenient since it eliminates the need to drop newly created objects and delete newly inserted records.
    • When developing code.
      • "onError": "continue", "atEnd": "rollbackOnError"
      • Use this sample when you want all statements to run so you can see and troubleshoot all errors and you want to commit all changes, but only when all SQL statements run successfully. This is the default setting because it is good for development and is still safe when these settings are accidentally deployed to production.
    • When running in production and test environments.
      • "onError": "stop", "atEnd": "rollbackOnError"
      • Use this sample when you want to immediately stop running SQL statements and rollback all changes when there is an error, but you want to commit all changes when all the SQL statements run successfully. This is useful in production because you want to commit a set of successfully executed SQL statements, but when a failure occurs, you want the server to immediately stop running the remaining SQL statements and roll back all changes. Immediately stopping execution and rolling back changes prevents server resources from being consumed unnecessarily.
    • When deploying database changes.
      • "onError": "continue", "atEnd": "commit"
      • Use this sample when you want to unconditionally commit all SQL statements even when an error occurs on one or more statements. This is useful for deploying database changes because it is common to ignore errors during a deployment process — for example, the DROP table command returns an error when dropping a table that does not exist. This error does not prevent a subsequent CREATE table from running successfully.