Specifying INOUT Parameters for a User-Defined Routine
UDRs that are written in the SPL, C, or Java™ languages can also support INOUT parameters. When the UDR is invoked, a value for each INOUT parameter is passed by reference as an argument to the UDR.
When the UDR completes execution, it can return a modified value
for the INOUT parameter to the calling context. The INOUT parameter
can be of any data type that HCL
OneDB™ supports,
including user-defined and complex data types, with the following
exceptions:
- Serial types (BIGSERIAL, SERIAL, and SERIAL8)
- Simple large object types (BYTE and TEXT).
In the following example, the CREATE PROCEDURE statement registers
a C routine that has a single INOUT parameter:
CREATE PROCEDURE CALC ( INOUT param1 float ) EXTERNAL NAME "$INFORMIXDIR/etc/myudr.so(calc)" LANGUAGE C;
An SPL routine can invoke other UDRs that have OUT or INOUT parameters, if those UDRs are written in the SPL or C language. An SPL routine cannot, however, invoke a Java UDR whose arguments include OUT or INOUT parameters.
Support for invoking UDRs that have named or unnamed ROW arguments
from an SPL routine has the following dependencies on the parameter
type of the ROW argument, and on the programming language of the invoked
UDR:
- SPL routines can invoke C UDRs that have ROW arguments that are IN parameters, but cannot invoke C UDRs that have ROW arguments that are OUT or INOUT parameters.
- SPL routines can invoke SPL UDRs that have ROW arguments of any parameter type, including IN, OUT, and INOUT.
You can assign INOUT parameters to statement-local variables (SLVs), which the section Statement-Local Variable Expressions describes.