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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:40:07+00:00 2026-05-25T12:40:07+00:00

This is kind of a question about best practices. I have a PL/SQL block

  • 0

This is kind of a question about best practices. I have a PL/SQL block similar to this

DECLARE

    --work variables

    PROCEDURE p1(in_parameter1, out_parameter1, out_parameter2...) IS
    BEGIN    
        --do stuff
        --select ( ... ) into ( ... ) from t1 where ( ... )
    END;

    PROCEDURE p2(in_parameter1, out_parameter1, out_parameter2...) IS
    BEGIN 
        --do stuff
        --insert/update tables
        --do more stuff
    END;    

BEGIN -- MAIN PROCESS STARTS HERE

    open c1;
    fetch c1 into c1RowData;
    EXIT WHEN c1%NOTFOUND    
     --call procedure1
     --do stuff
     --call procedure2
     --do stuff
     --do stuff
     --call procedure1
     --call procedure2
END;
/
EXIT;

The statements in procedures p1 and p2 could possibly raise exceptions ( NO_DATA_FOUND, DUP_VAL_ON_INDEX, … ).

What do you think is the best way to handle this exceptions? Should they be handled inside the procedures or do you think that I should surround every call the procedures in the main body with a TRY-CATCH block?

  • 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-25T12:40:07+00:00Added an answer on May 25, 2026 at 12:40 pm

    Personally I’d catch them inside the procedures they’re thrown from. This means that you have much more control with regards to how they’re handled externally. For example, you can throw them again as user defined exceptions which you can embellish with more information about exactly what went wrong.

    'Failed to find a matching row in table a for value b'
    

    is much more descriptive outside the procedure than

    'no data found'
    

    But this is realy dependent on:

    1. The error reporting requirements of the calling application
    2. The actual functionality implemented where you ‘do stuff’ within the procedures

    For example, say you wanted to run procedure 2 even though the select in procedure 1 found no rows.. You’d need to catch the exception in procedure 1 and ignore it. If you didn’t, then it’d be thrown to the exception handler in procedure 2.

    Or, say you wanted procedure 1 to insert a row in the case where the select didn’t find anything, in this case you’d need to catch the exception and perform the insert in the exception handler.

    Now, before anyone jumps on me, I’m not recommending you use exception handlers for contrlling the flow of execution within your code, these examples are the theoretical, but hopefully you get the idea..

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

Sidebar

Related Questions

As kind of a follow up to this question about prefixes , I agree
This is kind of more generic question, isn't language-specific. More about idea and algorithm
I have ask this kind of question before, but it seems my previous question
this kind of follows on from another question of mine. Basically, once I have
This question is kind of related to another question but I have a specific
This question more falls into the category of best practices, and clean/safe code for
This question kind of starts where this question ends up. MATLAB has a powerful
OK, this kind of follows on from my previous question . What I would
This question is kind of an add-on to this question In C#, a switch
This is kind of a weird question and more of an annoyance than technical

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.