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 9127091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:12:09+00:00 2026-06-17T07:12:09+00:00

I’m starting to work with PL/SQL and learning how to write procedures and exceptions

  • 0

I’m starting to work with PL/SQL and learning how to write procedures and exceptions but I cant seem to grasp how to show an error. The procedure is a simple one, its only supposed to do simple math as you can see below:

create or replace
procedure get_simple_math
  (n_num1 in number,
   n_num2 in number,
   n_answer out number,
   n_err_code out number,
   n_err_msg out varchar2)
as
begin
  n_answer := (n_num1 / n_num2);
  dbms_output.put_line('Answer is '||n_answer);

  n_err_code := 0;
exception
  when others
  then
    n_err_code := SQLCODE;
    n_err_msg := 'Error in get_simple_math '||SQLERRM;
    raise_application_error (-20002,n_err_msg);
end get_simple_math;

As you can see its nothing fancy, but I cant for the life of me get the block to run:

set serveroutput on
declare
  n_answer number := 0;
  n_err_code number;
  n_err_msg varchar2;
begin
  get_simple_math(10,5,n_answer);
end;

I’m assuming I need to declare the variables that are set to out, which is why they are there. I also tried adding them to the procedure execute like:

get_simple_math(10,5,n_answer,n_err_code,n_err_msg);

But that didn’t seem to do the trick, so I am just looking for some help in solving this problem. Thanks in advance.

  • 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-06-17T07:12:10+00:00Added an answer on June 17, 2026 at 7:12 am

    Run this and you’ll get your answer:

    declare
      n_answer number := 0;
      n_err_code number;
      --> n_err_msg varchar2; -- Incorrect
      n_err_msg varchar2(300);     -- Correct
    begin
      --> get_simple_math(10,5,n_answer); -- Incorrect call to proc...
      get_simple_math(10,5,n_answer, n_err_code, n_err_msg); -- add out parameters
    end;
    /
    

    General suggestion for the procedure part: use substr – optional:

      n_err_msg := 'Error in get_simple_math '||substr(SQLERRM, 1, 250);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I want to show the soap response to UIWebview.. my soap response is, <p><img
This could be a duplicate question, but I have no idea what search terms
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want to construct a data frame in an Rcpp function, but when I
I need to clean up various Word 'smart' characters in user input, including but
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

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.