EXTFNAPIV4_DESCRIBE_PARM_WIDTH Attribute (Get)

The EXTFNAPIV4_DESCRIBE_PARM_WIDTH attribute indicates the width of a parameter. Used in a describe_parameter_get scenario.

Data Type

a_sql_uint32

Description

The width of a parameter to a UDF. EXTFNAPIV4_DESCRIBE_PARM_WIDTH applies only to scalar parameters. Parameter width is the amount of storage, in bytes, required to store a parameter of the associated data type.

Usage

Gets the width of the parameter as defined in the CREATE PROCEDURE statement.

Returns

On success, returns the sizeof(a_sql_uint32).

On failure, returns one of the generic describe_parameter errors or:
  • EXTFNAPIV4_DESCRIBE_INVALID_STATE – get error returned if the query processing state is not greater than Initial.
  • EXTFNAPIV4_DESCRIBE_BUFFER_SIZE_MISMATCH – get error returned if the describe_buffer is not the size of a_sql_uint32.
  • EXTFNAPIV4_DESCRIBE_INVALID_PARAMETER – get error returned if the specified parameter is a table parameter. This includes parameter 0, or parameter n where n is an input table.

Query Processing States

Valid in:
  • Annotation state
  • Query Optimization state
  • Plan Building state
  • Execution state

Example

Sample procedure definition:

CREATE PROCEDURE my_udf(IN p1 INT, IN p2 char(100))
RESULT (x INT)
EXTERNAL NAME ‘my_udf@myudflib’;

Sample _describe_extfn API function code fragment:

my_udf_describe(a_v4_extfn_proc_context *cntxt)
{
	if( cntxt->current_state == EXTFNAPIV4_STATE_OPTIMIZATION ) {
	a_sql_uint32 width = 0;
	a_sql_int32 ret = 0;

	// Get the width of parameter 1
	ret = cntxt->describe_parameter_get( cntxt, 1, 
	EXTFNAPIV4_DESCRIBE_PARM_WIDTH,
	&width,
	sizeof(a_sql_uint32) );

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

	//Allocate some storage based on parameter width
	a_sql_byte *p = (a_sql_byte *)cntxt->alloc( cntxt, width )

	// Get the width of parameter 2
	ret = cntxt->describe_parameter_get( cntxt, 2,
		EXTFNAPIV4_DESCRIBE_PARM_WIDTH,
		&width,
		sizeof(a_sql_uint32) );
	if( ret <= 0 ) {
		// Handle the error.
	}

	// Allocate some storage based on parameter width
	char *c = (char *)cntxt->alloc( cntxt, width )
	
	…

}
}
Related concepts
Query Processing States
Related reference
EXTFNAPIV4_DESCRIBE_PARM_WIDTH Attribute (Set)
Generic describe_parameter Errors