{"id":2812,"date":"2019-08-07T01:49:23","date_gmt":"2019-08-07T08:49:23","guid":{"rendered":"https:\/\/oracletutorial.com\/?page_id=2812"},"modified":"2024-03-06T04:04:06","modified_gmt":"2024-03-06T11:04:06","slug":"plsql-raise-exception","status":"publish","type":"page","link":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/","title":{"rendered":"PL\/SQL Raise Exceptions"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to use the PL\/SQL <code>RAISE<\/code> statement to raise a user-defined exception, an internally defined exception, and re-raising an exception.<\/p>\n\n\n\n<p>To raise an <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-exception\/\">exception<\/a> explicitly, you use the <code>RAISE<\/code> statement. The <code>RAISE<\/code> statement allows you to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Raise a user-defined exception.<\/li>\n\n\n\n<li>Raise an internally defined exception.<\/li>\n\n\n\n<li>Reraising the current exception.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id='raising-a-user-defined-exception'>Raising a user-defined exception <a href=\"#raising-a-user-defined-exception\" class=\"anchor\" id=\"raising-a-user-defined-exception\" title=\"Anchor for Raising a user-defined exception\">#<\/a><\/h2>\n\n\n\n<p>A user-defined exception is defined by users like you or other developers in the declaration section of a block or subprogram.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='declaring-a-user-defined-exception'>Declaring a user-defined exception <a href=\"#declaring-a-user-defined-exception\" class=\"anchor\" id=\"declaring-a-user-defined-exception\" title=\"Anchor for Declaring a user-defined exception\">#<\/a><\/h3>\n\n\n\n<p>To define a user-defined exception, you use the following syntax:<\/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\">DECLARE<\/span>\n    exception_name <span class=\"hljs-keyword\">EXCEPTION<\/span>;<\/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>Similar to the <a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-variables\/\">variable declaration<\/a>, you declare an exception in the declaration section of a block.<\/p>\n\n\n\n<p>A user-defined exception must be assigned <span class=\"italic\"><code class=\"codeph\">error_code<\/code><\/span> . To do it, you use the <code class=\"codeph\">EXCEPTION_INIT<\/code> pragma as follows:<\/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\">PRAGMA<\/span> EXCEPTION_INIT (exception_name, error_code)<\/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>In this syntax, the <span class=\"italic\"><code class=\"codeph\">error_code<\/code><\/span> is an integer that ranges from <code>-20,999<\/code> to <code>-20,000<\/code>. And the <span class=\"italic\"><code class=\"codeph\">message<\/code><\/span> is a character string with a maximum length of <code>2,048<\/code> bytes.<\/p>\n\n\n\n<p>The entire syntax for declaring a user-defined exception is as follows:<\/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\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    exception_name <span class=\"hljs-keyword\">EXCEPTION<\/span>;\n    <span class=\"hljs-keyword\">PRAGMA<\/span> EXCEPTION_INIT (exception_name, error_number);<\/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<h3 class=\"wp-block-heading\" id='raising-a-user-defined-exception-example'>Raising a user-defined exception example <a href=\"#raising-a-user-defined-exception-example\" class=\"anchor\" id=\"raising-a-user-defined-exception-example\" title=\"Anchor for Raising a user-defined exception example\">#<\/a><\/h3>\n\n\n\n<p>The following example illustrates how to declare a user-defined exception and associate it with an error code.<\/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\"><span class=\"hljs-keyword\">DECLARE<\/span>\n    e_credit_too_high <span class=\"hljs-keyword\">EXCEPTION<\/span>;\n    <span class=\"hljs-keyword\">PRAGMA<\/span> exception_init( e_credit_too_high, <span class=\"hljs-number\">-20001<\/span> );\n    l_max_credit customers.credit_limit%TYPE;\n    l_customer_id customers.customer_id%TYPE := &amp;customer_id;\n    l_credit customers.credit_limit%TYPE := &amp;credit_limit;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- get the meax credit limit<\/span>\n    <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">MAX<\/span>(credit_limit) \n    <span class=\"hljs-keyword\">INTO<\/span> l_max_credit\n    <span class=\"hljs-keyword\">FROM<\/span> customers;\n    \n    <span class=\"hljs-comment\">-- check if input credit is greater than the max credit<\/span>\n    IF l_credit &gt; l_max_credit THEN \n        RAISE e_credit_too_high;\n    <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">IF<\/span>;\n    \n    <span class=\"hljs-comment\">-- if not, update credit limit<\/span>\n    <span class=\"hljs-keyword\">UPDATE<\/span> customers \n    <span class=\"hljs-keyword\">SET<\/span> credit_limit = l_credit\n    <span class=\"hljs-keyword\">WHERE<\/span> customer_id = l_customer_id;\n    \n    <span class=\"hljs-keyword\">COMMIT<\/span>;\n<span class=\"hljs-keyword\">END<\/span>;\n\/<\/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>In this example,<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, declare a user-defined exception <code>e_credit_too_high<\/code> and associate it with the error number <code>-20001<\/code>.<\/li>\n\n\n\n<li>Second, select the maximum credit from the <code>customers<\/code> table using the <code><a href=\"https:\/\/www.oracletutorial.com\/oracle-aggregate-functions\/oracle-max\/\">MAX()<\/a><\/code> function and assign this value to the <code>l_max_credit<\/code> variable.<\/li>\n\n\n\n<li>Third, check if the input credit with the maximum credit, if the input credit is greater than the max, then raise the <code>e_credit_too_high<\/code> exception.<\/li>\n\n\n\n<li>Finally, update the customer whose id is entered by the user with the new credit limit.<\/li>\n<\/ul>\n\n\n\n<p>Here is the output if you enter customer id 100 and credit limit <code>20000<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:plsql highlight:0 decode:true\">ORA-20001:<\/pre>\n\n\n\n<p>If you want to include a custom message, you can replace the line:<\/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\">RAISE e_credit_too_high;<\/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>by the following line:<\/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\">raise_application_error(-20001,'Credit is too high');<\/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<p>And execute the code block again, you will receive the following error:<\/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\">ORA-20001: Credit is too high<\/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<h2 class=\"wp-block-heading sect4\" id=\"LNPLS-GUID-4A73BF41-AA57-4F64-8E4C-265029BEEF39\" id='raising-an-internally-defined-exception'>Raising an internally defined exception <a href=\"#raising-an-internally-defined-exception\" class=\"anchor\" id=\"raising-an-internally-defined-exception\" title=\"Anchor for Raising an internally defined exception\">#<\/a><\/h2>\n\n\n\n<p>Typically, the runtime system raises internally defined exceptions implicitly when they occur. Besides, you can explicitly raise an internally defined exception with the <code>RAISE<\/code> statement if the exception has a name:<\/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\">RAISE exception_name;<\/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 example shows how to raise an internally defined exception <code>INVALID_NUMBER<\/code>:<\/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_customer_id customers.customer_id%<span class=\"hljs-keyword\">TYPE<\/span> := &amp;customer_id;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-comment\">-- get the meax credit limit<\/span>\n    <span class=\"hljs-keyword\">IF<\/span> l_customer_id &lt; <span class=\"hljs-number\">0<\/span> <span class=\"hljs-keyword\">THEN<\/span>\n        <span class=\"hljs-keyword\">RAISE<\/span> invalid_number;\n    <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">IF<\/span>;\n<span class=\"hljs-keyword\">END<\/span>;\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>If you execute the block and enter the customer id -10, you will get the following error:<\/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\">ORA-01722: invalid number<\/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 sect4\" id=\"LNPLS-GUID-59C4325C-9D2A-4D24-8381-79B676A508A8\" id='reraising-the-current-exception'>Reraising the current exception <a href=\"#reraising-the-current-exception\" class=\"anchor\" id=\"reraising-the-current-exception\" title=\"Anchor for Reraising the current exception\">#<\/a><\/h2>\n\n\n\n<p>You can re-raise the current exception with the <code>RAISE<\/code> statement. Reraising an exception passes it to the enclosing block, which later can be handled further. To reraise an exception, you don&#8217;t need to specify the exception name.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" 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    e_credit_too_high <span class=\"hljs-keyword\">EXCEPTION<\/span>;\n    <span class=\"hljs-keyword\">PRAGMA<\/span> exception_init( e_credit_too_high, <span class=\"hljs-number\">-20001<\/span> );\n    l_max_credit customers.credit_limit%TYPE;\n    l_customer_id customers.customer_id%TYPE := &amp;customer_id;\n    l_credit customers.credit_limit%TYPE     := &amp;credit_limit;\n<span class=\"hljs-keyword\">BEGIN<\/span>\n    <span class=\"hljs-keyword\">BEGIN<\/span>\n        <span class=\"hljs-comment\">-- get the max credit limit<\/span>\n        <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">MAX<\/span>(credit_limit) \n        <span class=\"hljs-keyword\">INTO<\/span> l_max_credit\n        <span class=\"hljs-keyword\">FROM<\/span> customers;\n        \n        <span class=\"hljs-comment\">-- check if input credit is greater than the max credit<\/span>\n        IF l_credit &gt; l_max_credit THEN \n            RAISE e_credit_too_high;\n        <span class=\"hljs-keyword\">END<\/span> <span class=\"hljs-keyword\">IF<\/span>;\n        EXCEPTION\n            WHEN e_credit_too_high THEN\n                dbms_output.put_line('The credit is too high' || l_credit);\n                RAISE; <span class=\"hljs-comment\">-- reraise the exception<\/span>\n    <span class=\"hljs-keyword\">END<\/span>;\nEXCEPTION\n    WHEN e_credit_too_high THEN\n        <span class=\"hljs-comment\">-- get average credit limit<\/span>\n        <span class=\"hljs-keyword\">SELECT<\/span> <span class=\"hljs-keyword\">avg<\/span>(credit_limit) \n        <span class=\"hljs-keyword\">into<\/span> l_credit\n        <span class=\"hljs-keyword\">from<\/span> customers;\n        \n        <span class=\"hljs-comment\">-- adjust the credit limit to the average<\/span>\n        dbms_output.put_line('Adjusted credit to ' || l_credit);\n    \n        <span class=\"hljs-comment\">--  update credit limit<\/span>\n        <span class=\"hljs-keyword\">UPDATE<\/span> customers \n        <span class=\"hljs-keyword\">SET<\/span> credit_limit = l_credit\n        <span class=\"hljs-keyword\">WHERE<\/span> customer_id = l_customer_id;\n   \n        <span class=\"hljs-keyword\">COMMIT<\/span>;\n<span class=\"hljs-keyword\">END<\/span>;\n\/<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><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 example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, get the maximum credit limit from the <code>customers<\/code> table.<\/li>\n\n\n\n<li>Second, compare the max credit with the user input credit. If the user-input credit is greater than the max credit, then raise the <code>e_credit_too_high<\/code>&nbsp;exception.<\/li>\n\n\n\n<li>Third, display a message and reraise the exception in the exception-handling section in the inner block.<\/li>\n\n\n\n<li>Finally, in the outer block, reassign the average credit to the <code>l_credit<\/code> variable and update the customer with the newly adjusted credit.<\/li>\n<\/ul>\n\n\n\n<p>If you enter the customer id 100 and credit limit 10000, the credit limit of the customer will be updated to the average credit.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">SELECT<\/span> * <span class=\"hljs-keyword\">FROM<\/span> customers \n<span class=\"hljs-keyword\">WHERE<\/span> customer_id = <span class=\"hljs-number\">100<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><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>Here is the output:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"608\" height=\"42\" src=\"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example.png\" alt=\"plsql raise exception example\" class=\"wp-image-2813\" srcset=\"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example.png 608w, https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example-300x21.png 300w\" sizes=\"auto, (max-width: 608px) 100vw, 608px\" \/><\/figure>\n\n\n\n<p>In this tutorial, you have learned how to use the PL\/SQL <code>RAISE<\/code> statement to explicitly raise a user-defined exception, an internally defined exception, and re-raising an exception.<\/p>\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=\"2812\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/\"\n\t\t\t\tdata-post-title=\"PL\/SQL Raise 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=\"2812\"\n\t\t\t\tdata-post-url=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/\"\n\t\t\t\tdata-post-title=\"PL\/SQL Raise 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 use the PL\/SQL RAISE statement to raise a user-defined exception, internally defined exception, and reraising an exception.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1418,"menu_order":16,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2812","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 RAISE Exceptions<\/title>\n<meta name=\"description\" content=\"Learn how to use the PL\/SQL RAISE statement to raise a user-defined exception, internally defined exception, and reraising an exception.\" \/>\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-raise-exception\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PL\/SQL RAISE Exceptions\" \/>\n<meta property=\"og:description\" content=\"Learn how to use the PL\/SQL RAISE statement to raise a user-defined exception, internally defined exception, and reraising an exception.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/\" \/>\n<meta property=\"og:site_name\" content=\"Oracle Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-06T11:04:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example.png\" \/>\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-raise-exception\\\/\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-raise-exception\\\/\",\"name\":\"PL\\\/SQL RAISE Exceptions\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-raise-exception\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-raise-exception\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.oracletutorial.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/plsql-raise-exception-example.png\",\"datePublished\":\"2019-08-07T08:49:23+00:00\",\"dateModified\":\"2024-03-06T11:04:06+00:00\",\"description\":\"Learn how to use the PL\\\/SQL RAISE statement to raise a user-defined exception, internally defined exception, and reraising an exception.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-raise-exception\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-raise-exception\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-raise-exception\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.oracletutorial.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/plsql-raise-exception-example.png\",\"contentUrl\":\"https:\\\/\\\/www.oracletutorial.com\\\/wp-content\\\/uploads\\\/2019\\\/08\\\/plsql-raise-exception-example.png\",\"width\":608,\"height\":42,\"caption\":\"plsql raise exception example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.oracletutorial.com\\\/plsql-tutorial\\\/plsql-raise-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 Raise 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":"PL\/SQL RAISE Exceptions","description":"Learn how to use the PL\/SQL RAISE statement to raise a user-defined exception, internally defined exception, and reraising an exception.","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-raise-exception\/","og_locale":"en_US","og_type":"article","og_title":"PL\/SQL RAISE Exceptions","og_description":"Learn how to use the PL\/SQL RAISE statement to raise a user-defined exception, internally defined exception, and reraising an exception.","og_url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/","og_site_name":"Oracle Tutorial","article_modified_time":"2024-03-06T11:04:06+00:00","og_image":[{"url":"https:\/\/oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example.png","type":"","width":"","height":""}],"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-raise-exception\/","url":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/","name":"PL\/SQL RAISE Exceptions","isPartOf":{"@id":"https:\/\/www.oracletutorial.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/#primaryimage"},"image":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/#primaryimage"},"thumbnailUrl":"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example.png","datePublished":"2019-08-07T08:49:23+00:00","dateModified":"2024-03-06T11:04:06+00:00","description":"Learn how to use the PL\/SQL RAISE statement to raise a user-defined exception, internally defined exception, and reraising an exception.","breadcrumb":{"@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-exception\/#primaryimage","url":"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example.png","contentUrl":"https:\/\/www.oracletutorial.com\/wp-content\/uploads\/2019\/08\/plsql-raise-exception-example.png","width":608,"height":42,"caption":"plsql raise exception example"},{"@type":"BreadcrumbList","@id":"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-raise-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 Raise 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\/2812","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=2812"}],"version-history":[{"count":0,"href":"https:\/\/www.oracletutorial.com\/wp-json\/wp\/v2\/pages\/2812\/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=2812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}