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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:27:38+00:00 2026-05-14T23:27:38+00:00

When I tried writing to an read-only parameter(IN) of a function, Oracle complains with

  • 0

When I tried writing to an read-only parameter(IN) of a function, Oracle complains with an error. But that is not the case when reading from an write-only(OUT) parameter of a function. Oracle silently allows this without any error. What is the reason for this behaviour?.
The following code executes without any assignment happening to “so” variable:

create or replace function foo(a OUT number) return number
  is
    so number;
  begin
    so := a; --no assignment happens here
    a := 42;
    dbms_output.put_line('HiYA there');
    dbms_output.put_line('VAlue:' || so);
    return 5;
  end;
/

declare 
  somevar number;
  a number := 6;
begin
  dbms_output.put_line('Before a:'|| a);
  somevar := foo(a);
  dbms_output.put_line('After a:' || a);
end;
/

Here’s the output I got:

Before a:6
HiYA there
VAlue:
After a:42
  • 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-14T23:27:39+00:00Added an answer on May 14, 2026 at 11:27 pm

    Reading from an OUT parameter is allowed: you could have written things in your OUT parameter at the beginning of a procedure and you might want to read the value it contains before returning, this is not a bug.

    What happens here is that since it is an OUT parameter and not an IN OUT parameter, the value of a is not passed to the function foo, so at the beginning of the procedure the OUT parameter a contains the NULL value. You can check this by commenting out the line a := 42; :

    SQL> create or replace function foo(a OUT number) return number
      2    is
      3      so number;
      4    begin
      5      so := a; --no assignment happens here
      6      /*a := 42;*/
      7      dbms_output.put_line('HiYA there');
      8      dbms_output.put_line('VAlue:' || so);
      9      return 5;
     10    end;
     11  /
    
    Function created
    SQL> declare
      2    somevar number;
      3    a number := 6;
      4  begin
      5    dbms_output.put_line('Before a:'|| a);
      6    somevar := foo(a);
      7    dbms_output.put_line('After a:' || a);
      8  end;
      9  /
    
    Before a:6
    HiYA there
    VAlue:
    After a:
             ^^ as you can see an OUT parameter is effectively "NULLed" at the
                beginning of a call
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing python script which gets links from website. But when I tried
I read this topic, but his problem maybe different from mine Writing to both
I'm trying to learn Lisp (elisp, actually), and I tried writing the following function
I'm writing an app for WM that handles incoming SMS events. I tried making
I'm writing a wrapper that forks an execv() process. Output from the child is
I am writing a small program that will read a plain ASCII text file
For processing a searchlog file I'm writing a Java class that should read and
I am writing a Chrome extension that synchronizes with Opera Link, but I keep
I tried out writing a pipelined version of Bitonic Sort using with File Read,
I've read tons of other questions and googled the issue, but I can only

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.