ResultSetMetaData and Function Return Values

ActiveSpaces determines the data types of the return values of functions used in queries at runtime. When the ResultSet for a query contains the return value of a function, VARCHAR is always reported as the data type for the value in the ResultSetMetaData.

To retrieve a function return value from the ResultSet as its actual data type, you must wait until the query is executed. After the query has been executed, the custom method ResultSetImplDG.getColumnType() can be called, which returns the actual result value type.

For example, suppose you have the following query:

SELECT COUNT(key) FROM mytable
The ResultSetMetaData reports that the data type for column 1 is VARCHAR. To retrieve the actual data type for column 1 of the query result do the following:
  1. Unwrap the ResultSet object retrieved when the query is executed. For example,

    ResultSetImplDG rsImpl = resultSet.unwrap(com.tibco.datagrid.jdbc.ResultSetImplDG.class);
  2. Retrieve the data type of column 1 in the ResultSet. For example,
    int columnType = rsimpl.getColumnType(1);
    
    The columnType will be set to a value from java.sql.Types to indicate the type of the value in the column. The java.sql.Types.NULL value is returned for columns in the row which do not contain a value.