Thursday 9 May 2013

PROCEDURAL PARAMETER MODES IN PLSQL

There are three modes, which tells the compiler, how to treat the actual parameters, used during call.


1.They are IN, OUT AND IN OUT.

2.The default is IN PARAMETER (calls are by reference)
  • Take values from calling environment.
  • Behaves like constant [during exec, sub-prog cant change value]
  • Actual parameter can be literals, expressions, or constants.
  • Can be assigned default values.

3.   OUT PARAMETER (calls are by value)
  • Must be specified, returns a value to calling environment.
  • Behaves like uninitialized variable.
a)Uninitialized variables hold nulls.
b)During exec, sub-program shall change value.
c)During exec, if not changed a null is returned to caller.
  • Actual parameter must be a variable. [Cannot be constant]
  • Cannot be assigned default values.

4.   IN OUT PARAMETER (calls are by value.)
  • Must be specified,
a)Shall take values from caller / returns a value to caller.
  • Behaves like initialized variable.
    a)Uninitialized variables hold nulls.
    b)During exec, sub-program shall change value.
    c)During exec, if not changed a old is returned to caller.
    d)Actual parameter must be a variable. [cannot be constant]
  • Actual parameter must be a variable. [cannot be constant]
  • Cannot be assigned default values. 

Note:To improve performance out and in out can be given a compiler hint no copy, requesting the compiler to pass by reference.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

ShareThis