{"id":1509,"date":"2017-11-21T16:55:07","date_gmt":"2017-11-21T09:55:07","guid":{"rendered":"https:\/\/oracletutorial.com\/?page_id=1509"},"modified":"2025-05-24T19:25:18","modified_gmt":"2025-05-25T02:25:18","slug":"plsql-exception","status":"publish","type":"page","link":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/","title":{"rendered":"PL\/SQL Exception"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: In this tutorial, you will learn about PL\/SQL exceptions and how to write exception handlers to handle exceptions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-plsql-exceptions'>Introduction to PL\/SQL Exceptions <a href=\"#introduction-to-plsql-exceptions\" class=\"anchor\" id=\"introduction-to-plsql-exceptions\" title=\"Anchor for Introduction to PL\/SQL Exceptions\">#<\/a><\/h2>\n\n\n\n<p><p>PL\/SQL treats all errors in an <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-anonymous-block\/\">anonymous block<\/a>, <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-procedure\/\">procedure<\/a>, or <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-function\/\">function<\/a> as exceptions.The exceptions can have different causes, such as:<\/p><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Coding mistakes<\/li>\n\n\n\n<li>Software bugs<\/li>\n\n\n\n<li>Hardware failures<\/li>\n<\/ul>\n\n\n\n<p>It is not possible to anticipate all potential exceptions. However, you can write code to handle exceptions to enable the program to continue running as usual.<\/p>\n\n\n\n<p>The code that you write to handle exceptions is called an <strong>exception handler<\/strong>.<\/p>\n\n\n\n<p>A <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-anonymous-block\/\">PL\/SQL block<\/a> may have an exception-handling section with one or more exception handlers.<\/p>\n\n\n\n<p>Here&#8217;s the basic syntax of the exception-handling section:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- executable section<\/span>\n    ...\n    <span class=\"hljs-comment\">-- exception-handling section<\/span>\n    <span class=\"hljs-keyword\">EXCEPTION<\/span> \n        <span class=\"hljs-keyword\">WHEN<\/span> e1 <span class=\"hljs-keyword\">THEN<\/span> \n            <span class=\"hljs-comment\">-- exception_handler1<\/span>\n        <span class=\"hljs-keyword\">WHEN<\/span> e2 <span class=\"hljs-keyword\">THEN<\/span> \n            <span class=\"hljs-comment\">-- exception_handler1<\/span>\n        <span class=\"hljs-keyword\">WHEN<\/span> OTHERS <span class=\"hljs-keyword\">THEN<\/span>\n            <span class=\"hljs-comment\">-- other_exception_handler<\/span>\n<span class=\"hljs-keyword\">END<\/span>;\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this syntax, <code>e1<\/code>, <code>e2<\/code> are exceptions.<\/p>\n\n\n\n<p>When an exception occurs in the executable section, the execution of the current block stops, and control transfers to the exception handling section:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If the exception <code>e1<\/code> occurred, the <code>exception_handler1<\/code> runs.<\/li>\n\n\n\n<li>If the exception <code>e2<\/code> occurred, the <code>exception_handler2<\/code> executes.<\/li>\n\n\n\n<li>In case any other exception arises, then the <code>other_exception_handler<\/code> runs.<\/li>\n<\/ul>\n\n\n\n<p>After an exception handler executes, control transfers to the following statement of the enclosing block.<\/p>\n\n\n\n<p>If there is no enclosing block, the control returns to the invoker if the exception handler is in a subprogram or host environment (SQL Developer or SQL*Plus) or an <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-anonymous-block\/\">anonymous block<\/a>.<\/p>\n\n\n\n<p>If an exception occurs but there is no exception handler, the <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception-propagation\/\">exception propagates<\/a>, which we will discuss in the <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception-propagation\/\">unhandled exception propagation tutorial<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='plsql-exception-examples'>PL\/SQL exception examples <a href=\"#plsql-exception-examples\" class=\"anchor\" id=\"plsql-exception-examples\" title=\"Anchor for PL\/SQL exception examples\">#<\/a><\/h2>\n\n\n\n<p>Let&#8217;s take some examples of handling exceptions.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='plsql-no_data_found-exception-example'>PL\/SQL NO_DATA_FOUND exception example <a href=\"#plsql-no_data_found-exception-example\" class=\"anchor\" id=\"plsql-no_data_found-exception-example\" title=\"Anchor for PL\/SQL NO_DATA_FOUND exception example\">#<\/a><\/h3>\n\n\n\n<p>The following block accepts a customer id as input and returns the customer&#8217;s name :<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    l_name customers.NAME%<span class=\"hljs-keyword\">TYPE<\/span>;\n    l_customer_id customers.customer_id%TYPE := &amp;customer_id;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- get the customer name by id<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">name<\/span> <span class=\"hljs-keyword\">INTO<\/span> l_name\n    <span class=\"hljs-keyword\">FROM<\/span> customers\n    <span class=\"hljs-keyword\">WHERE<\/span> customer_id = l_customer_id;\n\n    <span class=\"hljs-comment\">-- show the customer name   <\/span>\n    dbms_output.put_line('Customer name is ' || l_name);\n    \n<span class=\"hljs-keyword\">END<\/span>;\n\/\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you execute the block and enter the customer id as 0, Oracle will issue the following error:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">ORA-01403: no data found<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>The <code>ORA-01403<\/code> is a <strong>predefined exception<\/strong>.<\/p>\n\n\n\n<p>Note that the following line does not execute because control is transferred to the exception handling section.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">dbms_output.put_line('Customer name is ' || l_name);<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>To issue a more meaningful error message, you can add an exception-handling section as follows:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    l_name customers.NAME%<span class=\"hljs-keyword\">TYPE<\/span>;\n    l_customer_id customers.customer_id%TYPE := &amp;customer_id;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- get the customer<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">NAME<\/span> <span class=\"hljs-keyword\">INTO<\/span> l_name\n    <span class=\"hljs-keyword\">FROM<\/span> customers\n    <span class=\"hljs-keyword\">WHERE<\/span> customer_id = l_customer_id;\n    \n    <span class=\"hljs-comment\">-- show the customer name   <\/span>\n    dbms_output.put_line('customer name is ' || l_name);\n\n    EXCEPTION \n        WHEN NO_DATA_FOUND THEN\n            dbms_output.put_line('Customer ' || l_customer_id ||  ' does not exist');\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\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>If you execute this code block and enter the customer id 0, you will get the following message:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">Customer 0 does not exist<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id='plsql-too_many_rows-exception-example'>PL\/SQL TOO_MANY_ROWS exception example <a href=\"#plsql-too_many_rows-exception-example\" class=\"anchor\" id=\"plsql-too_many_rows-exception-example\" title=\"Anchor for PL\/SQL TOO_MANY_ROWS exception example\">#<\/a><\/h3>\n\n\n\n<p>First, modify the code block in the above example as follows and execute it:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    l_name customers.name%<span class=\"hljs-keyword\">TYPE<\/span>;\n    l_customer_id customers.customer_id%TYPE := &amp;customer_id;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- get the customer<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">name<\/span> <span class=\"hljs-keyword\">INTO<\/span> l_name\n    <span class=\"hljs-keyword\">FROM<\/span> customers\n    <span class=\"hljs-keyword\">WHERE<\/span> customer_id &lt;= l_customer_id;\n    \n    <span class=\"hljs-comment\">-- show the customer name   <\/span>\n    dbms_output.put_line('Customer name is ' || l_name);\n\n    EXCEPTION \n        WHEN NO_DATA_FOUND THEN\n            dbms_output.put_line('Customer ' || l_customer_id ||  ' does not exist');\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\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Second, enter the customer id 10 and you&#8217;ll get the following error:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">ORA-01422: exact fetch returns more than requested number of rows<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This is another exception called <code>TOO_MANY_ROWS<\/code> which was not handled by the code.<\/p>\n\n\n\n<p>Third, add the exception handler for the <code>TOO_MANY_ROWS<\/code> exception:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    l_name customers.NAME%<span class=\"hljs-keyword\">TYPE<\/span>;\n    l_customer_id customers.customer_id%TYPE := &amp;customer_id;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- get the customer<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">NAME<\/span> <span class=\"hljs-keyword\">INTO<\/span> l_name\n    <span class=\"hljs-keyword\">FROM<\/span> customers\n    <span class=\"hljs-keyword\">WHERE<\/span> customer_id &gt; l_customer_id;\n    \n    <span class=\"hljs-comment\">-- show the customer name   <\/span>\n    dbms_output.put_line('Customer name is ' || l_name);\n    EXCEPTION \n        WHEN NO_DATA_FOUND THEN\n            dbms_output.put_line('Customer ' || l_customer_id ||  ' does not exist');\n        WHEN TOO_MANY_ROWS THEN\n            dbms_output.put_line('The database returns more than one customer');    \n<span class=\"hljs-keyword\">END<\/span>;\n\/\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Finally, if you execute the code, enter 10 as the customer id. You will see that the code will not raise any exceptions and issue the following message:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\">The database returns more than one customer<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id='plsql-exception-categories'>PL\/SQL exception categories <a href=\"#plsql-exception-categories\" class=\"anchor\" id=\"plsql-exception-categories\" title=\"Anchor for PL\/SQL exception categories\">#<\/a><\/h2>\n\n\n\n<p>PL\/SQL has three exception categories:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Internally defined exceptions<\/strong> are errors that arise from the Oracle Database environment. The runtime system raises internally defined exceptions automatically. ORA-27102 (out of memory) is one example. Note that internally defined exceptions do not have names but an error code.<\/li>\n\n\n\n<li><strong>Predefined exceptions<\/strong> are errors that occur during the execution of the program. The predefined exceptions are internally defined exceptions that PL\/SQL has given names, e.g., <code>NO_DATA_FOUND<\/code>, <code>TOO_MANY_ROWS<\/code>.<\/li>\n\n\n\n<li><strong>User-defined exceptions<\/strong> are custom exceptions defined by users like you. User-defined exceptions must be raised explicitly.<\/li>\n<\/ul>\n\n\n\n<p>The following table illustrates the differences between exception categories.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Category<\/th><th>Definer<\/th><th>Has Error Code<\/th><th>Has Name<\/th><th>Raised Implicitly<\/th><th>Raised Explicitly<\/th><\/tr><\/thead><tbody><tr><td>Internally defined<\/td><td>Runtime system<\/td><td>Always<\/td><td>Only if you assign one<\/td><td>Yes<\/td><td>Optionally<\/td><\/tr><tr><td>Predefined<\/td><td>Runtime system<\/td><td>Always<\/td><td>Always<\/td><td>Yes<\/td><td>Optionally<\/td><\/tr><tr><td>User-defined<\/td><td>User<\/td><td>Only if you assign one<\/td><td>Always<\/td><td>No<\/td><td>Always<\/td><\/tr><\/tbody><\/table><\/figure>\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>PL\/SQL treats all errors as exceptions.<\/li>\n\n\n\n<li>Use exception handlers to handle exceptions, allowing programs to continue execution.<\/li>\n\n\n\n<li>When an exception occurs, PL\/SQL stops the current block and transfers control to the exception-handling section.<\/li>\n\n\n\n<li>PL\/SQL has three exception categories: internally defined, predefined, and user-defined.<\/li>\n\n\n\n<li>If an exception occurs and you don&#8217;t handle it, PL\/SQL will propagate it.\u00a0<\/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=\"1509\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/\"\n\t\t\t\tdata-post-title=\"PL\/SQL Exception\"\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=\"1509\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/\"\n\t\t\t\tdata-post-title=\"PL\/SQL Exception\"\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>This tutorial shows you how to deal with PL\/SQL exception such as declaring user-defined exception, raising an exception and handling it.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1418,"menu_order":15,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1509","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>PL\/SQL Exception<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to deal with PL\/SQL exception such as declaring user-defined exception, raising an exception and handling it.\" \/>\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\/plsql-exception\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PL\/SQL Exception\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to deal with PL\/SQL exception such as declaring user-defined exception, raising an exception and handling it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/\" \/>\n<meta property=\"og:site_name\" content=\"Oracle Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-25T02:25:18+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=\"3 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\\\/plsql-exception\\\/\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-exception\\\/\",\"name\":\"PL\\\/SQL Exception\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\"},\"datePublished\":\"2017-11-21T09:55:07+00:00\",\"dateModified\":\"2025-05-25T02:25:18+00:00\",\"description\":\"This tutorial shows you how to deal with PL\\\/SQL exception such as declaring user-defined exception, raising an exception and handling it.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-exception\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-exception\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-exception\\\/#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\":\"PL\\\/SQL Exception\"}]},{\"@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":"PL\/SQL Exception","description":"This tutorial shows you how to deal with PL\/SQL exception such as declaring user-defined exception, raising an exception and handling it.","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\/plsql-exception\/","og_locale":"en_US","og_type":"article","og_title":"PL\/SQL Exception","og_description":"This tutorial shows you how to deal with PL\/SQL exception such as declaring user-defined exception, raising an exception and handling it.","og_url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/","og_site_name":"Oracle Tutorial","article_modified_time":"2025-05-25T02:25:18+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/","url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/","name":"PL\/SQL Exception","isPartOf":{"@id":"https:\/\/www.oracletutorial.com\/#website"},"datePublished":"2017-11-21T09:55:07+00:00","dateModified":"2025-05-25T02:25:18+00:00","description":"This tutorial shows you how to deal with PL\/SQL exception such as declaring user-defined exception, raising an exception and handling it.","breadcrumb":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/#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":"PL\/SQL Exception"}]},{"@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\/1509","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=1509"}],"version-history":[{"count":0,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/1509\/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=1509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}