Database exceptions are raised when there is an error related to the database management system.

For example, the requested operation would violate some database constraint because you are trying to create a record that already exists or you are duplicating information in a unique index.

Another common situation that can raise a database exception is when you are trying to create/update data in some entity that will not fit there. Imagine you have an entity with a text attribute of size 20. If you assign the expression "Record updated at " + CurrentDateTime() to some record attribute variable, and use an  Entity Action to update the database, an exception will be raised. See Database data types.

Attempts to violate relationships Delete Rules, more specifically, the Protect rule, will also raise a database exception.

You may handle database exceptions whenever you are interacting with the database engine, such as, when using an aggregate, an SQL query or an entity action.

Usually, a database exception should be caught at the action flow level.

Handling Database Exceptions

To handle database exceptions, simply set your error hander to have the 'Exception' property set to 'Database'.

See Also

Handle Exceptions | Exception Flow