There can be any number of parameters in PLSQL programming environment Each parameters has a mode and a type. The possible modes are IN (read-only), OUT (write-only), and INOUT (read and write). There can be any number of parameters in PLSQL programming environment, Each parameters has a mode and a type. The possible modes are IN (read-only), OUT (write-only), and INOUT (read and write). IN, OUT and INOUT Modes
Values are passed to a procedure in three modes; IN, OUT and INOUT. The mode which a variable is passed defines how the variables can be used inside the procedure.
IN Mode (Read Only)
Default By operation
IN mode can be read and used by the procedure/function but can not be changed and it cannot be assigned a value(except Default) in an operation. Variables passed using IN mode can be considered as a constant. It is recommended for maintainability reasons to always define the variable passing
mode when you define the variable.
OUT Mode(write-Only)
A variable passed in OUT mode is used to pass information back from the procedure to the calling program. It is a write-only variable and has no value until the block assigns it a value. Internally, an OUT variable is created and not initialized when the procedure is called. When the procedure ends, the variable value (upon ending) is copied to the variable passed in the call. As such, a variable passed in OUT mode can not be assigned a default value nor can it be read inside the procedure. Because the variable value is copied back to the passed variable when the procedure terminates, the calling code can not pass an OUT variable a literal value. If the procedure raises an exception that is not caught, it will result in the OUT variable not being copied when the procedure terminates. INOUT, for example, means that the parameter will receive a value and return another
INOUT Mode ( Read Write)
A variable passed in INOUT mode has characteristics of both the IN and the OUT mode. The variable value is passed in and can be read by the procedure. The procedure can also change the value and it will be copied back to the passed variable when the procedure completes. Like a variable passed in OUT mode, an INOUT variable can not have a default value and can not be passed as a literal. If the procedure terminates abnormally (as in an exception) the INOUT variable will not be copied back to the variable passed in.
Consider The Following 2 Example and Analyze the the cause of error...Read the above to understand why error incase you need more help POST ON COMMENT SECTION OF THE ARTICLE FOR SOLUTON
create or replace procedure demo1
(a in number := 10,
b in number := 20)
as
begin
n_1 := n_2 + 30;
end;
/
create or replace procedure demo2
(a in number := 10,
b in number := 20
c out number :=30)
as
begin
null;
end;
/
Note : Never Use Constrained parameter declaration while declaring any parameter in a plsql programs which are being invoked.For example, CHAR(10) and VARCHAR(20) are illegal; CHAR or VARCHAR should be used instead. The actual length of a parameter depends on the corresponding argument that is passed in
when the procedure is invoked.