{"id":2859,"date":"2019-08-09T00:40:30","date_gmt":"2019-08-09T07:40:30","guid":{"rendered":"https:\/\/oracletutorial.com\/?page_id=2859"},"modified":"2025-05-24T20:05:23","modified_gmt":"2025-05-25T03:05:23","slug":"oracle-sqlcode","status":"publish","type":"page","link":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/","title":{"rendered":"Handling Other Unhandled Exceptions"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: In this tutorial, you will learn how to handle other unhandled exceptions in the <code>WHEN OTHER<\/code> clause using <code>SQLCODE<\/code> and <code>SQLERRM<\/code> functions.<\/p>\n\n\n\n<p>In this <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/\">exception<\/a> handling section, you can include the <code>WHEN OTHERS<\/code> clause to catch any otherwise unhandled exceptions:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">EXCEPTION<\/span>\n    ...\n    <span class=\"hljs-keyword\">WHEN<\/span> OTHERS\n        <span class=\"hljs-comment\">-- catch other exceptions<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Because you handle other non-specific exceptions in the <code>WHEN OTHERS<\/code> clause, you will need to take advantages of the built-in error functions such as <code>SQLCODE<\/code> and <code>SQLERRM<\/code>.<\/p>\n\n\n\n<p class=\"note\">Note that you cannot use <code>SQLCODE<\/code> or <code>SQLERRM<\/code> function directly in an SQL statement. Instead, you must first assign their returned values to <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-variables\/\">variables<\/a>, and then use the variables in the SQL statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='sqlcode-function'>SQLCODE function <a href=\"#sqlcode-function\" class=\"anchor\" id=\"sqlcode-function\" title=\"Anchor for SQLCODE function\">#<\/a><\/h2>\n\n\n\n<p>The <code>SQLCODE<\/code> function accepts no argument and returns a number code of the most recent exception.<\/p>\n\n\n\n<p>If the exceptions are internal, <code>SQLCODE<\/code> returns a negative number except for the <code>NO_DATA_FOUND<\/code> exception which has the number code +100.<\/p>\n\n\n\n<p>If the exception is user-defined, <code>SQLCODE<\/code> returns +1 or the number that you associated with the exception via the pragma <code>EXCEPTION_INIT<\/code>.<\/p>\n\n\n\n<p>The <code>SQLCODE<\/code> is only usable in the exception handling section. If you use the <code>SQLCODE<\/code> function outside an exception handler, it always returns zero.<\/p>\n\n\n\n<p>This example illustrates how to use the <code>SQLCODE<\/code> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    l_code NUMBER;\n    r_customer customers<span class=\"hljs-meta\">%rowtype<\/span>;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">INTO<\/span> r_customer <span class=\"hljs-keyword\">FROM<\/span> customers;\n    \n    <span class=\"hljs-keyword\">EXCEPTION<\/span> \n        <span class=\"hljs-keyword\">WHEN<\/span> OTHERS <span class=\"hljs-keyword\">THEN<\/span>\n        l_code := SQLCODE;  \n        dbms_output.put_line(<span class=\"hljs-string\">'Error code:'<\/span> || l_code);\n<span class=\"hljs-keyword\">END<\/span>;\n\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, we try to fetch too many rows into a record, which results in an error with the following error code:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">Error code:<span class=\"hljs-number\">-1422<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='sqlerrm-function'>SQLERRM function <a href=\"#sqlerrm-function\" class=\"anchor\" id=\"sqlerrm-function\" title=\"Anchor for SQLERRM function\">#<\/a><\/h2>\n\n\n\n<p>The function <code>SQLERRM<\/code> takes an argument as an error number and returns the error message associated with that error number:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-built_in\">SQLERRM<\/span>(&#91;error_number])<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, the <code>error_number<\/code> can be any valid Oracle error number.<\/p>\n\n\n\n<p>If you omit the <code>error_number<\/code> argument, the function will return the error message associated with the current value of <code>SQLCODE<\/code>.<\/p>\n\n\n\n<p>Note that the <code>SQLERRM<\/code> function with no argument is only useful in an exception handler.<\/p>\n\n\n\n<p>This example illustrates how to use the function <code>SQLERRM<\/code> in an exception handler:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    l_msg VARCHAR2(<span class=\"hljs-number\">255<\/span>);\n    r_customer customers<span class=\"hljs-meta\">%rowtype<\/span>;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">INTO<\/span> r_customer <span class=\"hljs-keyword\">FROM<\/span> customers;\n    \n    <span class=\"hljs-keyword\">EXCEPTION<\/span> \n        <span class=\"hljs-keyword\">WHEN<\/span> OTHERS <span class=\"hljs-keyword\">THEN<\/span>\n        l_msg := <span class=\"hljs-built_in\">SQLERRM<\/span>;  \n        dbms_output.put_line(l_msg);\n<span class=\"hljs-keyword\">END<\/span>;\n\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Here is the output:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\">ORA<span class=\"hljs-number\">-01422<\/span>: exact <span class=\"hljs-keyword\">fetch<\/span> <span class=\"hljs-keyword\">returns<\/span> more than requested number <span class=\"hljs-keyword\">of<\/span> <span class=\"hljs-keyword\">rows<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='using-sqlcode-and-sqlerrm-functions-example'>Using SQLCODE and SQLERRM functions example <a href=\"#using-sqlcode-and-sqlerrm-functions-example\" class=\"anchor\" id=\"using-sqlcode-and-sqlerrm-functions-example\" title=\"Anchor for Using SQLCODE and SQLERRM functions example\">#<\/a><\/h2>\n\n\n\n<p>The following example <a href=\"https:\/\/www.oracletutorial.com\/oracle-basics\/oracle-insert\/\">inserts<\/a> a new contact into the <code>contacts<\/code> table in the <a href=\"https:\/\/www.oracletutorial.com\/getting-started\/oracle-sample-database\/\">sample database<\/a>. It has an exception handler in the <code>WHERE OTHERS<\/code>\u00a0 clause of the exception handling section.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"PostgreSQL SQL dialect and PL\/pgSQL\" data-shcb-language-slug=\"pgsql\"><span><code class=\"hljs language-pgsql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    l_first_name  contacts.first_name<span class=\"hljs-meta\">%TYPE<\/span> := <span class=\"hljs-string\">'Flor'<\/span>;\n    l_last_name   contacts.last_name<span class=\"hljs-meta\">%TYPE<\/span> := <span class=\"hljs-string\">'Stone'<\/span>;\n    l_email       contacts.email<span class=\"hljs-meta\">%TYPE<\/span> := <span class=\"hljs-string\">'flor.stone@raytheon.com'<\/span>;\n    l_phone       contacts.phone<span class=\"hljs-meta\">%TYPE<\/span> := <span class=\"hljs-string\">'+1 317 123 4105'<\/span>;\n    l_customer_id contacts.customer_id<span class=\"hljs-meta\">%TYPE<\/span> := <span class=\"hljs-number\">-1<\/span>;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- insert a new contact<\/span>\n    <span class=\"hljs-keyword\">INSERT<\/span> <span class=\"hljs-keyword\">INTO<\/span> contacts(first_name, last_name, email, phone, customer_id)\n    <span class=\"hljs-keyword\">VALUES<\/span>(l_first_name, l_last_name, l_email, l_phone, l_customer_id);\n    \n    <span class=\"hljs-keyword\">EXCEPTION<\/span> \n        <span class=\"hljs-keyword\">WHEN<\/span> OTHERS <span class=\"hljs-keyword\">THEN<\/span>\n            <span class=\"hljs-keyword\">DECLARE<\/span>\n                l_error PLS_INTEGER := SQLCODE;\n                l_msg VARCHAR2(<span class=\"hljs-number\">255<\/span>) := <span class=\"hljs-built_in\">sqlerrm<\/span>;\n            <span class=\"hljs-keyword\">BEGIN<\/span>\n                <span class=\"hljs-keyword\">CASE<\/span> l_error \n                <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-number\">-1<\/span> <span class=\"hljs-keyword\">THEN<\/span>\n                    <span class=\"hljs-comment\">-- duplicate email<\/span>\n                    dbms_output.put_line(<span class=\"hljs-string\">'duplicate email found '<\/span> || l_email);\n                    dbms_output.put_line(l_msg);\n                    \n                <span class=\"hljs-keyword\">WHEN<\/span> <span class=\"hljs-number\">-2291<\/span> <span class=\"hljs-keyword\">THEN<\/span>\n                    <span class=\"hljs-comment\">-- parent key not found<\/span>\n                    dbms_output.put_line(<span class=\"hljs-string\">'Invalid customer id '<\/span> || l_customer_id);\n                    dbms_output.put_line(l_msg);\n                <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">CASE<\/span>;\n                <span class=\"hljs-comment\">-- reraise the current exception<\/span>\n                <span class=\"hljs-keyword\">RAISE<\/span>;\n            <span class=\"hljs-keyword\">END<\/span>;\n            \n<span class=\"hljs-keyword\">END<\/span>;\n\/\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PostgreSQL SQL dialect and PL\/pgSQL<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">pgsql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this example, the exception handler traps two exceptions -1 (duplicate email ) and -2291 (parent key not found). It shows a custom message and reraises the exception using the <code>RAISE<\/code> statement.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the <code>SQLCODE<\/code> and <code>SQLERRM<\/code> functions to handle other unhandled exceptions in the <code>WHEN OTHER<\/code> clause.<\/li>\n<\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"2859\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/\"\n\t\t\t\tdata-post-title=\"Handling Other Unhandled Exceptions\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"2859\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/\"\n\t\t\t\tdata-post-title=\"Handling Other Unhandled Exceptions\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to handle other unhandled exceptions in the WHEN OTHER clause using SQLCODE and SQLERRM functions.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1418,"menu_order":19,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2859","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Handling Unhandled Exceptions<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to handle other unhandled exceptions in the WHEN OTHER clause using SQLCODE and SQLERRM functions.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Handling Unhandled Exceptions\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to handle other unhandled exceptions in the WHEN OTHER clause using SQLCODE and SQLERRM functions.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/\" \/>\n<meta property=\"og:site_name\" content=\"Oracle Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-25T03:05:23+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/oracle-sqlcode\\\/\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/oracle-sqlcode\\\/\",\"name\":\"Handling Unhandled Exceptions\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\"},\"datePublished\":\"2019-08-09T07:40:30+00:00\",\"dateModified\":\"2025-05-25T03:05:23+00:00\",\"description\":\"In this tutorial, you will learn how to handle other unhandled exceptions in the WHEN OTHER clause using SQLCODE and SQLERRM functions.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/oracle-sqlcode\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/oracle-sqlcode\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/oracle-sqlcode\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.oracletutorial.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"PL\\\/SQL Tutorial\",\"item\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Handling Other Unhandled Exceptions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/\",\"name\":\"Oracle Tutorial\",\"description\":\"Oracle Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.oracletutorial.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Handling Unhandled Exceptions","description":"In this tutorial, you will learn how to handle other unhandled exceptions in the WHEN OTHER clause using SQLCODE and SQLERRM functions.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/","og_locale":"en_US","og_type":"article","og_title":"Handling Unhandled Exceptions","og_description":"In this tutorial, you will learn how to handle other unhandled exceptions in the WHEN OTHER clause using SQLCODE and SQLERRM functions.","og_url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/","og_site_name":"Oracle Tutorial","article_modified_time":"2025-05-25T03:05:23+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/","url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/","name":"Handling Unhandled Exceptions","isPartOf":{"@id":"https:\/\/www.oracletutorial.com\/#website"},"datePublished":"2019-08-09T07:40:30+00:00","dateModified":"2025-05-25T03:05:23+00:00","description":"In this tutorial, you will learn how to handle other unhandled exceptions in the WHEN OTHER clause using SQLCODE and SQLERRM functions.","breadcrumb":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/oracle-sqlcode\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.oracletutorial.com\/"},{"@type":"ListItem","position":2,"name":"PL\/SQL Tutorial","item":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/"},{"@type":"ListItem","position":3,"name":"Handling Other Unhandled Exceptions"}]},{"@type":"WebSite","@id":"https:\/\/www.oracletutorial.com\/#website","url":"https:\/\/www.oracletutorial.com\/","name":"Oracle Tutorial","description":"Oracle Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.oracletutorial.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/2859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/comments?post=2859"}],"version-history":[{"count":0,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/2859\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/1418"}],"wp:attachment":[{"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/media?parent=2859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}