## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> RAISE_ERROR[RAISE_ERROR]
RAISE_ERROR --> End((END))
```
## Purpose
The `RAISE_ERROR` SQL function raises an error from SQL with the specified error code and error message. The error is only raised when the expression is actually evaluated, enabling raising errors depending on the outcome of a query.
Parameters:
- Error code (`varchar2`): the error code. A default error code is used when `null` or empty.
- Error message (`varchar2`): the error message. A default error message is used when `null` or empty.
- Kind request (optional, `varchar2`): the kind of request.
- Natural key (optional, `varchar2`): the natural key of the data involved.
Returns: the function does not return a value; evaluation raises an error.
## Examples
The following example raises an error with a custom error code and message:
```sql
select raise_error('itgenboe123', 'The value is not allowed')
itgenboe123: The value is not allowed
```
The following example raises an error only for rows with a negative amount:
```sql
select case
when amount < 0
then raise_error('itgenboe124', 'A negative amount is not allowed')
else amount
end
from ( select 1 amount union all select -1 )
```