## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR Start((START)) --> SQLERRM[SQLERRM]:::quoted SQLERRM --> End((END)) ``` ## Purpose The `SQLERRM` SQL function gets the error message of the last SQL error that occurred during execution. The function can be used without parentheses. See also [[SQLCODE]] and [[SQLROWCOUNT]]. Returns: the error message of the last error as `varchar2`. Returns `null` when no error occurred. ## Examples The following example retrieves the error message of the last error; the output is empty since no error occurred: ```sql select sqlerrm ------------------- ``` The following example first raises a division-by-zero error and then retrieves the error message of the last error: ```sql select 1 / 0 itgenttn082: Division of 1 by zero is impossible. ``` ```sql select sqlerrm -------------------------------------------------- itgenttn082: Division of 1 by zero is impossible. ``` The following example catches a division-by-zero error and raises a new application error with the error message provided by `SQLERRM`: ```sql declare x pls_integer; begin x := 1 / 0; exception when others then raise_application_error('sample', sqlerrm); end; sample: itgenttn082: Division of 1 by zero is impossible. ```