Specifying OUT Parameters for User-Defined Routines
When you register a user-defined routine of Informix®, you can use the OUT keyword to specify that any parameter in the list is an OUT parameter. Each OUT parameter corresponds to a value the routine returns indirectly, through a pointer. The value that the routine returns through the pointer is an extra value, in addition to any values that it returns explicitly.
After you have registered a user-defined function that has one or more OUT parameters, you can use the function with a statement-local variable (SLV) in a SELECT statement. (For information about statement-local variables, see Statement-Local Variable Expressions.)
If you specify any OUT parameters, and you use Informix-style parameters, the arguments are passed to the OUT parameters by reference. The OUT parameters are not significant in determining the routine signature.
int my_func( int x, int *y );
CREATE FUNCTION my_func( x INT, OUT y INT )
RETURNING INT
EXTERNAL NAME "/usr/lib/local_site.so"
LANGUAGE C
END FUNCTION;
public static String allVarchar(String arg1, String[] arg2)
throws SQLException
{
arg2[0] = arg1;
return arg1;
}
CREATE FUNCTION all_varchar(VARCHAR(10), OUT VARCHAR(7))
RETURNING VARCHAR(7)
WITH (class = "jvp")
EXTERNAL NAME 'informix.testclasses.jlm.Param.allVarchar(java.lang.String,
java.lang.String[ ])'
LANGUAGE JAVA;