SQLite Forum

RAISE (ROLLBACK | ABORT | FAIL) differences?

RAISE (ROLLBACK | ABORT | FAIL) differences?

(1) By anonymous on 2020-09-06 22:59:13 [link] [source]

Looking at the RAISE function it is not clear what each one of the options does.

For example, if I use ABORT inside a transaction, it will not be rolled back? Or, if I use ROLLBACK outside a transaction, will it fail as there was no transaction active? And how's FAIL different?

Is there some more detailed documentation?

The only one which appears obvious is the IGNORE option although its purpose escapes me. Examples?

(2) By J. King (jking) on 2020-09-06 23:58:54 in reply to 1 [link] [source]

See the documentation on ON CONFLICT for details on what each does.

(3) By Keith Medcalf (kmedcalf) on 2020-09-07 00:27:40 in reply to 1 [source]

You cannot possibly use these outside a transaction because in order for them to be "activated" you must be inside a transaction.

You will note that in the absence of "explicit" transaction control, then each "statement" executes within its own transaction context on the connection.

In the case of multiple overlapping transaction contexts on the same connection, and in the absence of "explicit" transaction control, the "transaction context" begins when the first of multiple overlapping statements commences execution and completes when the last overlapping statement is reset.

Note also that in the face of "explicit transaction control" and multiple overlapping statement executions on the same connection that although the transaction may be commenced "explicitly", the "explicit" request to "end" the transaction (COMMIT/ROLLBACK) has incomplete effect until the last statement concurrently executing on that connection is also reset (that is, the COMMIT/ROLLBACK of the changed data will occur immediately, however, the "read" transaction context will remain in effect until all outstanding statements on that connection are reset).

Perhaps the documentation with respect to explicit transaction control will be helpful: