Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 728497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:41:18+00:00 2026-05-14T06:41:18+00:00

In my code i am entering the salary which is not available in employees

  • 0

In my code i am entering the salary which is not available in employees table and then again inserting duplicate employee_id in primary key column of employee table in exception block where i am handling no data found exception but i do not why No data found exception in the end also?

OUTPUT coming:

Enter some other sal
ORA-01400: cannot insert NULL into ("SCOTT"."EMPLOYEES"."LAST_NAME")
ORA-01403: no data found  --This should not come according to logic

This is the code:

DECLARE
v_sal number:=&p_sal;
v_num number;
BEGIN
   BEGIN
            select salary INTO v_num from employees where salary=v_sal;
   EXCEPTION
           WHEN no_data_found THEN
                   DBMS_OUTPUT.PUT_LINE('Enter some other sal');

           INSERT INTO employees (employee_id)values(100) ;
   END;
EXCEPTION
   WHEN OTHERS THEN
   DBMS_OUTPUT.PUT_LINE(sqlerrm);
END;       
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:41:18+00:00Added an answer on May 14, 2026 at 6:41 am

    The behaviour is that errors hurled in the EXCEPTIONS block get concatenated to SQLERRM, and hence propagated upwards. I grant you it is not documented but we can clearly see it here:

    SQL> declare
      2      v_sal t23.sal%type := 230;
      3      l_num t23.sal%type;
      4  begin
      5      begin
      6          begin
      7              select sal into l_num
      8              from t23 where sal = v_sal;
      9          exception
     10              when no_data_found then
     11                  dbms_output.put_line('inner exception::'||sqlerrm);
     12                  insert into t23  values (99, 'MR KNOX', v_sal);
     13          end;
     14      exception
     15          when dup_val_on_index then
     16              dbms_output.put_line('middle exception::'||sqlerrm);
     17              insert into t23 (id, sal) values (99, v_sal);
     18      end;
     19  exception
     20      when others then
     21          dbms_output.put_line('outer exception::'||sqlerrm);
     22  end;
     23  /
    inner exception::ORA-01403: no data found
    middle exception::ORA-00001: unique constraint (APC.T23_PK) violated
    ORA-01403: no data found
    outer exception::ORA-01400: cannot insert NULL into ("APC"."T23"."LAST_NAME")
    ORA-00001: unique constraint (APC.T23_PK) violated
    ORA-01403: no data found
    
    PL/SQL procedure successfully completed.
    
    SQL>  
    

    Note: if there is a nested exception block which successfully handles the thrown exception it is not concatenated to SQLERRM. That is, the SQLERRM consists of a stack of unsucessfully handled exceptions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After entering code to create a new table in SQL ORACLE, would the changes
The following code is not entering the i for loop. I have had problems
I am borrowing this code that was entering strings (user, message) into shoutbox table
When entering a code line in Aptana Studio like <input id=send type=button value=Send onclick=calculate()
Code: <?php //initializing script, do not modify session_start(); define('IN_SCRIPT', true); //so that global.php cannot
When entering code in CMS static block(possible page as well) and in this code
Is it possible to color the user entering code (inside a textarea) using jquery.
I am using this code to prevent entering special chars String.prototype.isText = function ()
The QLineEdit is for entering post code. User may also input city name, while
I Declare Web Page Anonymous via entering this Code, <location path=Routing.aspx > The Above

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.