Get CSV Column Value (CSV_VAL | CSV_VARCHAR | CSV_CHAR) UDF

There are two alternate versions of this Function: CSV_VARCHAR and CV_CHAR that perform identical functions.

Index

Schema IQUERY

CSV_VAL( csv_data, header => 'column header' );

or

CSV_VAL( csv_data, ID => relative-column ID );

The CSV Value (CSV_VAL) User Defined Function parses the csv_data passed to it and returns the data for the column identified by the 2nd parameter. The 2nd parameter may be the relative column number or the column heading.

This Function is primarily used with the iQuery CSV() UDTF to parse the CSV content.

Returned Value

VARCHAR(256)

This UDF returns the column content as a VARCHAR(256) value. It can and often is, CAST to the specific length needed for the application. For example if the Company name column should be returned as a 30 character value, then casting the column might look like the following:

 CAST( iQuery.csv_val(data, 'company name') as varchar(30) )

Parameters

CSV_DATA

Expected value:  DATA

The column DATA is returned from the iQuery CSV() UDTF. The parameter should be the column named "data" as returned by the CSV() UDTF. Any other value indicates customization of the interface and may produce undesirable results.

HEADER

When the HEADER version of this UDF is used, the column heading (enclosed in single quotes) is specified to identify the column whose data is to be returned.

ID

When the Relative Column ID version of this UDF is used, ID identifies the relative column number whose data is returned.