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

  • Home
  • SEARCH
  • 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 8054813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:13:57+00:00 2026-06-05T08:13:57+00:00

In my stored procedure I have the following statement IF (sdate > sysdate) THEN

  • 0

In my stored procedure I have the following statement

IF (sdate > sysdate)
            THEN
                RAISE exec_not_allowed;
                                returnval := sdate;

            END IF;

returnval is IN OUT parameter in my procedure.

In java normally an OUT parameter is fetched by using:

callablestatement.getInt(2);

How can I receive returnval in Java if an exception is raised? The exception error code is captured in the Java SQLException part.

  • 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-05T08:13:58+00:00Added an answer on June 5, 2026 at 8:13 am

    Why are you raising an exception at all in this situation? You should only really raise an exception in two situations:

    1. You intend to catch the exception and deal with it appropriately in the calling code.
    2. Something is wrong and you want your application to crash and burn.

    You’re not doing either of these things, and don’t need to. You just want to stop the code running and “return” (it’s a procedure) your value. In this case I would suggest using return.

    return ends the execution of the anonymous block that contains it and, in a procedure, returns “control” to the calling statement. i.e. it fits the bill perfectly.

    The following code assigns sdate to your out parameter before halting the execution of the procedure, using return. “More stuff” will never occur.

    create or replace procedure my_procedure_one (returnval in out date) is
    begin
    
       -- some stuff.
       if sdate > sysdate then
          returnval := sdate;
          -- we don-t want to continue any more if this is true.
          return;
       end if;
       -- more stuff.
    end;
    

    If you only want to assign sdate to returnval if the condition is not true then you simply swap round these two lines; maybe taking it out of the if statement to make it more obvious. This is what your code does at the moment as when you raise exec_not_allowed all execution is stopped.

    create or replace procedure my_procedure_two (returnval in out date) is
    begin
    
       -- some stuff.
    
       -- we don-t want to continue any more if this is true.
       if sdate > sysdate then
          return;
       end if;
    
       returnval := sdate;
       -- more stuff.
    end;
    

    In either case your Java call remains the same. In the first procedure (my_procedure_one) you’ll get sdate returned and in the second a null, assuming that returnval hadn’t been previously assigned.

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

Sidebar

Related Questions

I have the following stored procedure which will generate mon to sun and then
I have the following statement in a stored procedure: DECLARE @Count INT EXEC @Count
I have a stored procedure which uses a FOR XML statement at the end
I have the following code within a stored procedure. WHERE WPP.ACCEPTED = 1 AND
I have the following iBatis mapping for an Oracle Stored Procedure that returns a
I am using Oracle 10g and I have the following stored procedure: CREATE OR
I have a mysql stored procedure which is giving me the following error:- #1064
I have the following C code which uses a stored procedure to insert 2
Using a stored procedure i have a fairly complex SQL statement which returns a
I am using the following code to consume a CUBRID database java stored procedure.

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.