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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:32:08+00:00 2026-05-24T21:32:08+00:00

In my function below I am trying to understand why it only returns BLAH

  • 0

In my function below I am trying to understand why it only returns BLAH if I pass in 01356666 and then a null value for anything else passed in. My expectation was that it would return BLAH regardless of what was passed in since I reset the str_mgrin_out after I do the SELECT INTO. I have been testing this in Oracle 10g.

CREATE OR REPLACE FUNCTION GET_MANAGERGIN2 (str_empgin_in IN varchar2)
RETURN varchar2
AS
str_mgrgin_out varchar2(10);
BEGIN
  SELECT 'FOO' INTO str_mgrgin_out FROM dual WHERE str_empgin_in = '01356666';

  str_mgrgin_out := 'BLAH';

  RETURN str_mgrgin_out;
END GET_MANAGERGIN2;
/

-- Returns null but expecting BLAH
SELECT GET_MANAGERGIN2('00356666') FROM dual;
-- Returns BLAH
SELECT GET_MANAGERGIN2('01356666') FROM dual;
  • 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-24T21:32:09+00:00Added an answer on May 24, 2026 at 9:32 pm

    I’d assume that this is because if the SELECT INTO doesn’t return exactly one value into str_mgrgin_out it’ll throw an exception, so the str_mgrgin_out := 'BLAH'; line never gets executed.

    I think the error would be ORA-01403.

    Try adding an exception handler at the end as:

    Exception
        When Others Then
             str_mgrgin_out := 'BLAH';
    

    You might have to surround it with a BEGIN...END as well so it would be:

    CREATE OR REPLACE FUNCTION GET_MANAGERGIN2 (str_empgin_in IN varchar2)
    RETURN varchar2
    AS
    str_mgrgin_out varchar2(10);
    BEGIN
        BEGIN
            SELECT 'FOO' INTO str_mgrgin_out FROM dual WHERE str_empgin_in = '01356666';
    
            str_mgrgin_out := 'BLAH';
            Exception
                When Others THen
                    str_mgrgin_out := 'BLAH';
       END;
       RETURN str_mgrgin_out;
    END GET_MANAGERGIN2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to understand within my lesson how to read the below function called
I am trying to understand what are the differences between $.getScript function in jQuery
I'm trying to understand why people use a wrap function for my event handlers.
I'm trying to understand how to select the right overloaded function template at compile-time
I am trying to solve the question below, but I do not understand it
I am trying to understand scope in the below scenario. When calling searchTerms ,
I am trying to better understand how a function works. I am not familiar
can anyone please help with the below code. I am trying to understand multiple
I'm trying to understand 2 different lines of code below. My javascript is weak,
I am trying to understand the output of the program printed below. When I

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.