Table of Contents Previous Next



Create collection types NUMBER_ARRAY and CHAR_ARRAY in the Advanced Server database:
Listing 1.17-a is an SPL function that uses collection types NUMBER_ARRAY and CHAR_ARRAY as IN parameters and CHAR_ARRAY as the OUT parameter.
The function concatenates the employee ID from the NUMBER_ARRAY IN parameter with the employee name in the corresponding row from the CHAR_ARRAY IN parameter. The resulting concatenated entries are returned in the CHAR_ARRAY OUT parameter.
A CallableStatement object is prepared to invoke the concatEmpIdName() function:
createArrayOf() initializes and creates collections named empIdArray and empNameArray:
The call to registerOutParameter() registers the parameter type (Types.ARRAY) of the OUT parameter:
The setObject() method binds the collections empIdArray and empNameArray to the IN placeholders:
A call to stmt.execute() invokes the concatEmpIdName() function:
getArray() retrieves the collection returned by the function. The first two rows consisting of the concatenated employee IDs and names are displayed:


Table of Contents Previous Next