EXTFNAPIV4_DESCRIBE_PARM_TABLE_ORDERBY Attribute (Set)

The EXTFNAPIV4_DESCRIBE_PARM_TABLE_ORDERBY attribute indicates the order of rows in the table. Used in a describe_parameter_set scenario.

Data Type

a_v4_extfn_orderby_list

Description

The order of rows in the table. This property is only valid for argument 0 and table arguments.

Usage

This attribute allows the UDF code to:
  • Determine if the input TABLE parameter has been ordered
  • Declare that the result set is ordered.

If the parameter number is 0, then the attribute refers to the outbound result set. If the parameter is > 0 and the parameter type is a table then the attribute refers to the input TABLE parameter.

The order is specified by the a_v4_extfn_orderby_list, which is a structure supporting a list of column ordinals and their associated ascending or descending property. If the UDF sets the order by property for the outbound result set, the server is then able to perform order by optimizations. For example, if the UDF produced ascending order on the first result set column, the server will eliminate a redundant order by request on the same column.

If the UDF does not set the orderby property on the outbound result set, the server assumes the data is not ordered.

If the UDF sets the orderby property on the input TABLE parameter, the server guarantees data ordering for the input data. In this scenario, the UDF describes to the server that the input data must be ordered. If the server detects a runtime conflict it raises a SQL exception. For example, when the UDF describes that the first column of the input TABLE parameter must have ascending order and the SQL statement contains a descending clause, the server raises a SQL exception.

In the event that the SQL did not contain an ordering clause, the server automatically adds the ordering to ensure that input TABLE parameter is ordered as required.

Returns

If successful, returns the number of bytes copied from a_v4_extfn_orderby_list.

Query Processing States

Valid in:

Related concepts
Query Processing States
Related reference
EXTFNAPIV4_DESCRIBE_PARM_TABLE_ORDERBY Attribute (Get)