To help ensure your successful use of the built-in routines and views, certain coding practices are recommended. These practices are especially important because routines might change from release to release and also within releases, such as through fix packs, as enhancements are made.
SELECT * FROM TABLE(MON_GET_UNIT_OF_WORK(NULL,-1)) AS t
ORDER BY total_cpu_time DESC
SELECT application_handle,
uow_id,
total_cpu_time,
app_rqsts_completed_total,
rqsts_completed_total
FROM TABLE(MON_GET_UNIT_OF_WORK(NULL,-1)) AS t
ORDER BY total_cpu_time DESC
Naming columns prevents problems if the sequence and number of columns in the routines change. The number of result columns that a routine returns might increase. If, for example, you provide only five host variables when the routine returns six result columns, your application will break.
In addition, the type and size of output parameters or result columns of routines might change. For example, a column might change from VARCHAR(8) to VARCHAR(128), or an INTEGER column might become a BIGINT column. If a variable that you use is too small, the data that you receive from the routine might be truncated.
strcpy(strStmt, "SELECT application_handle, uow_id,total_cpu_time
FROM TABLE(MON_GET_UNIT_OF_WORK(NULL,-1))
AS t ORDER BY total_cpu_time DESC");
EXEC SQL PREPARE stmt FROM :strStmt;
EXEC SQL DESCRIBE stmt into :*pSqlda;
For an example of how to use the information that is returned in the SQL description area (SQLDA), see the RowDatamemoryAlloc function in the samples/c/tbread.sqc file.
ResultSet rs = pstmt.executeQuery();
ResultSetMetaData rsms = rs.getMetaData();
For an example of how to use the metadata of the result
set, see the execPreparedQueryWithUnknownOutputColumn( ) method in the samples/java/jdbc/TbRead.java file.