Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Oracle Procedure Parameter

Posted on 2003-03-04
3
Medium Priority
?
635 Views
Last Modified: 2008-02-01
Hi All,

Can any one tell me about the difference and functionality of IN , OUT , INOUT type parameter in procedure , what will be the functionality for each one and how they will effect for package and my program.

ajay
0
Comment
Question by:ajay_erdci
  • 2
3 Comments
 
LVL 5

Expert Comment

by:jpkemp
ID: 8070114
IN: parameter is passed in
OUT: parameter is passed out
IN OUT: parameter is passed in and passed out

For IN, the argument value in the caller will not change, even if the procedure changes it internally.

For OUT, the argument value cannot be read by the procedure until the procedure itself writes it.

For OUT and IN OUT, the argument must be a writeable variable (i.e. not a literal).

Jeff
0
 
LVL 1

Author Comment

by:ajay_erdci
ID: 8070353
Dear Jeff,

can you explain it with any example then only it will be fisible for me.

Thanks in advance,
ajay
0
 
LVL 5

Accepted Solution

by:
jpkemp earned 300 total points
ID: 8076353
PROCEDURE myfunction (
  a IN NUMBER,
  b OUT NUMBER,
  c IN OUT NUMBER ) IS
BEGIN
  dbms_output.put_line('In myfunction');
  dbms_output.put_line('A=' || a);
  --dbms_output.put_line('B=' || b); --This is illegal
  dbms_output.put_line('C=' || c);
  dbms_output.put_line('Processing');
  --a := 1; --This is illegal
  b := 2;
  c := 3;
  dbms_output.put_line('A=' || a);
  --dbms_output.put_line('B=' || b); --This is illegal
  dbms_output.put_line('C=' || c);
END;

...

PROCEDURE test
  x NUMBER;
  y NUMBER;
  z NUMBER;
BEGIN
  x := 4;
  y := 5;
  z := 6;
  dbms_output.put_line('X=' || x);
  dbms_output.put_line('Y=' || y);
  dbms_output.put_line('Z=' || z);
  myfunction(x, y, z);
  dbms_output.put_line('In test');
  dbms_output.put_line('X=' || x);
  dbms_output.put_line('Y=' || y);
  dbms_output.put_line('Z=' || z);
  --myfunction(1,2,3); -- this is illegal
END;

-----

Expected output of test:

X=4
Y=5
Z=6
In myfunction
A=4
C=6
Processing
A=4
C=3
In test
X=4
Y=2
Z=3

Analyse the above output and you'll see.
The last function call ("myfunction(1,2,3)") is illegal because OUT and IN OUT parameters must be given arguments which are writable variables, not literals or constants.

Jeff
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Microsoft Jet database engine errors can crop up out of nowhere to disrupt the working of the Exchange server. Decoding why a particular error occurs goes a long way in determining the right solution for it.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question