Explain IN, OUT and INOUT in procedures

Explain IN, OUT and INOUT in procedures.

Values passed to on oracle function can be either of type IN, OUT or INOUT which decides how variables can be used within the procedure.

IN : A variable passed in this mode is of read only nature. This is to say, the value cannot be changed and its scope is restricted within the procedure. The procedure receives a value from this argument when the procedure is called.

OUT : In this mode, a variable is write only and can be passed back to the calling program. It cannot be read inside the procedure and needs to be assigned a value.

INOUT : This procedure has features of both IN and OUT mode. The procedure can also read the variables value and can also change it to pass it to the calling function.

Explain IN, OUT and INOUT in procedures.

IN, OUT and INOUT are the arguments that are passed to the procedures.

- IN is a 'read only' argument and must be initialised.
- OUT is an uninitialised argument which must be initialized by a function.
- INOUT - A combination of the two above. That is, an initialised argument which can be written to
What are the rules of writing package?
Packeges are PL/SQl constructs that allow related data to be stored together. A package has two parts: specification and a body......
What are the use of Export and Import command?
Use the IMPORT command to import data into a nickname from a file and the EXPORT command to export data from a nickname to a file.....
Parameters to be provided while executing Export and Import commands
The parameters that need to be provided while executing IMPORT or EXPORT commands are:...
Post your comment
Discussion Board
Explain IN, OUT and INOUT in procedures.
IN parameter can read value but can not be overwritten. If I attempt to modify an IN
For example:
SQL> create or replace procedure p( x in number )
as
begin
dbms_output.put_line( 'x = ' || x );
x := 55;
end;
/
Procedure created with compilation errors.

IN OUT parameter can read value and can be overwritten.
SQL> create or replace procedure p( x in out number )
as
begin
dbms_output.put_line( 'x = ' || x );
x := 55;
end;
/
Procedure created.

An OUT parameter can read value and can be overwritten however an OUT only parameter is always assigned NULL on the way into the routine.
SQL> create or replace procedure p( x in out number )
as
begin
dbms_output.put_line( 'x = ' || x );
x := 55;
end;
/
Procedure created.
Paul Nersesov 04-17-2012