A parameter is an optional list of parameters that you define both pass information into the procedure and send information out of procedure back to the calling program. Parameter is also known as argument. When you define a parameter, you also specify the way in which it can be used. There are three different modes of parameter or argument.
1. Actual Parameters :
The arguments that are passed in a function call are called actual arguments. These arguments are defined in the calling function. These are the variables or expressions referenced in the parameter list of a subprogram call. There is no need to specify datatype in actual parameter.
// X and Y NUMBER ARE ACTUAL PARAMETERSSQL> CREATE OR REPLACE FUNCTION FUNC1(X NUMBER,
Y NUMBER)
2 RETURN NUMBER IS
3 R NUMBER;
4 BEGIN
5 R:=X+Y;
6 RETURN(R);
7 END;
8 /
FUNCTION CREATED.
SQL>|
2. Formal Parameters :These are the variables or expressions referenced in the parameter list of a subprogram specification. The datatype of the receiving value must be defined. The scope of formal arguments is local to the function definition in which they are used.
Example :
SQL> DECLARE2 N1 NUMBER:=10;
3 N2 NUMBER:=20;
4 S NUMBER;
5 BEGIN
6 S:=FUNC1(N1, N2);
7 DBMS_OUTOUT.PUT_LINE('RESULT IS: '||S);
8 END;
9 /
OUTPUT: RESULT IS: 30
PL/SQL PROCEDURE SUCCESSFULLY COMPLETED.
SQL>|