19.0.0 released Nov 08, 2023
On error

Purpose: Either exit request or continue processing when there is an error in executing a query.

on-error ( exit | continue ) [ @<database> ]

When a database statement (like run-query) fails, either exit request processing if "exit" is used, or continue if "continue" is used. "Exiting" is equivalent to calling report-error with the message containing details about the error. "Continuing" means that your program will continue but you should examine error code (see "error" clause in run-query) and handle any issues.

The default action is "exit". You can switch back and forth between "exit" and "continue". Typically, "exit" is preferable because errors in database SQL code generally mean application issues, i.e. bugs that need fixing, however "continue" may be used when application wants to attempt to recover from errors or perform other actions.

Note that you can override the effect of on-error for a specific query by using "on-error-continue" and "on-error-exit" clauses in run-query.
Database
Optional <database> is specified in "@" clause and is the name of the database-config-file.
Examples
The following will not exit when errors happen but rather continue execution (and you must check every error henceforth):
on-error continue @mydb

See also
Database
begin-transaction  
commit-transaction  
current-row  
database-config-file  
database-queries  
delete-query  
on-error  
prepared-statements  
query-result  
rollback-transaction  
run-query    Error handling
error-code  
error-handling  
on-error  
report-error    
See all
documentation


You are free to copy, redistribute and adapt this web page (even commercially), as long as you give credit and provide a dofollow link back to this page - see full license at CC-BY-4.0. Copyright (c) 2019-2023 Dasoftver LLC. Vely and elephant logo are trademarks of Dasoftver LLC. The software and information on this web site are provided "AS IS" and without any warranties or guarantees of any kind. Icons from table-icons.io copyright PaweĊ‚ Kuna, licensed under MIT license.