EXTFNAPIV4_DESCRIBE_COL_MAXIMUM_VALUE (Set)

The EXTFNAPIV4_DESCRIBE_COL_MAXIMUM_VALUE attribute indicates the maximum value for the column. Used in a describe_column_set scenario.

Data Type

an_extfn_value

Description

The maximum value for a column. This property is valid only for argument 0 and table arguments.

Usage

The UDF can set EXTFNAPIV4_DESCRIBE_COL_MAXIMUM_VALUE, if it knows what the maximum data value of the column is. The server can use this information during optimization.

The UDF can use EXTFNAPIV4_DESCRIBE_COL_TYPE to determine the data type of the column, and EXTFNAPIV4_DESCRIBE_COL_WIDTH to determine the storage requirements of the column, to provide an equivalently sized buffer to hold the value to set.

describe_buffer_length is the sizeof() this buffer.

Returns

On success, returns the describe_buffer_length, if the value was set, or:

On failure, returns one of the generic describe_column errors, or:

Query Processing States

Valid in:

Example

The PROCEDURE definition and and UDF code fragment that implements the _describe_extfn callback 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 shows a TPF where it is useful to the server (or to another TPF that takes the result of this TPF as input) to know the maximum value of result set column one. In this instance, the maximum output value of column one is 500000.

my_tpf_describe(a_v4_extfn_proc_context *cntxt)
{
    if( cntxt->current_state == EXTFNAPIV4_STATE_OPTIMIZATION ) {
	     a_sql_int32 max_value = 500000;
	     a_sql_int32 ret = 0;

	     // Tell the server what the maximum value of the first column
	     // of our result set will be.

      ret = cntxt->describe_column_set( cntxt, 0, 1 
		          EXTFNAPIV4_DESCRIBE_COL_MAXIMUM_VALUE,
		          &max_value,
		          sizeof(a_sql_int32) );

	     if( ret < 0 ) {
	         // Handle the error.
     	}

   }
}
Related concepts
Query Processing States
Related reference
EXTFNAPIV4_DESCRIBE_COL_MAXIMUM_VALUE (Get)
EXTFNAPIV4_DESCRIBE_COL_TYPE (Get)
EXTFNAPIV4_DESCRIBE_COL_TYPE (Set)
EXTFNAPIV4_DESCRIBE_COL_WIDTH (Get)
EXTFNAPIV4_DESCRIBE_COL_WIDTH (Set)
Generic describe_column Errors