The EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE attribute indicates the minimum value for a column. Used in a describe_column_get scenario.
an_extfn_value
The minimum value for a column, if available. Valid only for argument 0 and table arguments.
If a UDF gets the EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE property, the minimum value of the column data is returned in the describe_buffer. If the input table is a base table, the minimum value is based on all of the column data in the table and is accessible only if there is an index on the table column. If the input table is the result of another UDF, the minimum value is the EXTFNAPIV4_DESCRIBE_COL_TYPE set by that UDF.
The data type for this property is different for different columns. The UDF can use EXTFNAPIV4_DESCRIBE_COL_TYPE to determine the data type of the column. The UDF can also use EXTFNAPIV4_DESCRIBE_COL_WIDTH to determine the storage requirements of the column,to provide an equivalently sized buffer to hold the value.
describe_buffer_length allows the server to determine if the buffer is valid.
If the EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE property is unavailable, describe_buffer is NULL.
On failure, returns one of the generic describe_column errors, or:
The procedure definition and code fragment in the _describe_extfn API function:
CREATE PROCEDURE my_tpf( col_char char(10), col_table TABLE( c1 INT, c2 INT ) ) RESULTS ( r1 INT, r2 INT, r3 INT ) EXTERNAL ‘my_tpf_proc@mylibrary’; CREATE TABLE T( x INT, y INT, z INT ); select * from my_tpf( 'test', TABLE( select x,y from T ) )
This example illustrates how a TPF would get the minimum value for column two of the input table, for internal optimization purposes.
my_tpf_describe(a_v4_extfn_proc_context *cntxt) { if( cntxt->current_state > EXTFNAPIV4_STATE_INITIAL ) { a_sql_int32 min_value = 0; a_sql_int32 ret = 0; // Get the minimum value of the second column of the // table input parameter 'col_table' ret = cntxt->describe_column_get( cntxt, 2, 2 EXTFNAPIV4_DESCRIBE_COL_MINIMUM_VALUE, &min_value, sizeof(a_sql_int32) ); if( ret < 0 ) { // Handle the error. } } }