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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:22:23+00:00 2026-05-17T18:22:23+00:00

I know for more than one result, you don’t have much choice for using

  • 0

I know for more than one result, you don’t have much choice for using out parameters, but I’m wondering whats the difference between the following 2 cases where there’s one out parameter.

Say I have two stored procedures:

CREATE PROCEDURE no_out_params(IN foo INT)
BEGIN
  SELECT foo + 1 as result;
END

and

CREATE PROCDURE with_out_params(IN foo INT, OUT result INT)
BEGIN
  SET result = foo + 1;
END

Then using JDBC I can either:

CallableStatement c1 = conn.prepareCall("{ call no_out_params(?)}");
c1.setInt(1, 5);
ResultSet rs = c1.executeQuery();
if (rs.next()) {
  return rs.getInt("result"); // or rs.getInt(1)
}

or

CallableStatement c1 = conn.prepareCall("{ call with_out_params(?, ?)}");
c1.setInt(1, 5);
c1.registerOutParameter(2, Types.INT);
c1.executeQuery();
return c1.getInt(2);

Assuming you’re properly closing everything in try/finally’s (omitted for brevity), does the non-out parameter method provide any advantage? If not, is it reasonable to assume that one should always use out parameters (if only to to be consistent in cases where there’s more than one result)?

  • 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-17T18:22:24+00:00Added an answer on May 17, 2026 at 6:22 pm

    Assuming you’re properly closing everything in try/finally’s (omitted for brevity), does the non-out parameter method provide any advantage?

    The advantage is being able to retrieve the result set (in any language, Java/etc) without having to define all the OUT parameters (extra work for no value).

    If you’re only returning one value, you might want to see if a FUNCTION would work instead.

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

Sidebar

Related Questions

Alright I know this is more than likely a amateur question but I have
for some reason (and I think I know why), when more than one row
So I'm making an android app that has more than 100 buttons,but you know
Summary: Ivy is downloading more jars than I expect and I don't know why.
Can I record more than one channel at the same time either using MediaRecorder
I know that a 32-bit OS cannot see more than 4 GB of RAM.
Does anyone know a better (shorter/more elegant) way than simply writing a loop and
I know more or less how to do this, but I think I'm getting
I know there is this post , but I still want to know more
It appears that NHibernate cannot automap more than one IList of a given type

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.