DEV Community

AntDB
AntDB

Posted on

AntDB-Oracle Compatibility Developer's Manual P4–9

Parameter Modes

As discussed earlier, the mode of a parameter can be one of the three modes IN, OUT, or IN OUT. The characteristics of the following formal parameters depend on its mode.

  • How the formal parameter is initialized when the procedure or function is called.

  • Whether the procedure or function being called can modify the formal parameter.

  • How the actual parameter passes the value from the calling procedure to the called procedure.

  • How to handle formal parameters when the called program has an unhandled exception.

The behavior of each parameter is summarized in the following table according to the parameter's mode.

Pattern Properties Input parameters Output parameters Input-Output Parameters
The formal parameter is initialized to : Actual parameter value Actual parameter value Actual parameter value
Can the formal parameters be modified by the called program? No Yes Yes
After the normal end of the called program The contents of the actual parameter. The original before the call The value of the actual parameter The value of the last formal parameter The value of the last formal parameter
After the called program encounters a handled exception. The original before the call The value of the actual parameter The value of the last formal parameter The value of the last formal parameter
Actual parameter after the called program encountered an exception that was not handled. The original before the call The value of the actual parameter The value of the original real parameter before the call The value of the original actual parameter before the call

As shown in the table above, an IN form parameter is only initialized as an actual parameter at the time of the call, unless it is explicitly initialized with a default value; the IN parameter may be referenced in the called program, and the called program may not assign a new value to the input parameter. When the called application finishes running and returns to the calling program, the actual parameters contain the same values as they did before the application was called.

The OUT formal parameter is only initialized to the actual parameter at the time of the call. The called application can refer to and assign a new value to the formal parameter. If the called program ends normally and no exception is thrown. Then the value of the actual parameter is the value assigned to the formal parameter at the last time. If a handled exception is encountered, the value of the actual parameter is the value most recently assigned to the formal parameter.

If an exception is thrown that cannot be handled, the value of the actual parameter is still the value assigned before the call.

As with an IN parameter, an IN OUT formal parameter is initialized to the actual parameter when it is called. Like an OUT parameter, an IN OUT formal parameter can be modified by the called program, and if the called application ends normally without an exception, the value of the previously set formal parameter is passed to the actual parameter of the calling program. If a handleable exception is encountered, the value of the actual parameter is the value last assigned to the formal parameter. If an unhandleable exception is thrown, the value of the actual parameter remains the value that was assigned before the call.

Top comments (0)