Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions
  8. Creating Custom Functions
  9. Custom Function API Reference

Transformation Language Reference

Transformation Language Reference

FIRST

FIRST

Returns the first value found within a port or group. Optionally, you can apply a filter to limit the rows the
PowerCenter Integration Service
reads. You can nest only one other aggregate function within FIRST.

Syntax

FIRST(
value
[,
filter_condition
] )
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
value
Required
Any datatype except Binary. Passes the values for which you want to return the first value. You can enter any valid transformation expression.
filter_condition
Optional
Limits the rows in the search. The filter condition must be a numeric value or evaluate to TRUE, FALSE, or NULL. You can enter any valid transformation expression.

Return Value

First value in a group.
NULL if all values passed to the function are NULL or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

Nulls

If a value is NULL, FIRST ignores the row. However, if all values passed from the port are NULL, FIRST returns NULL.
By default, the
PowerCenter Integration Service
treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the
PowerCenter Integration Service
, you can choose how you want to handle null values in aggregate functions. You can treat null values as 0 in aggregate functions or as NULL.

Group By

FIRST groups values based on group by ports you define in the transformation, returning one result for each group.
If there is no group by port, FIRST treats all rows as one group, returning one value.

Examples

The following expression returns the first value in the ITEM_NAME port with a price greater than $10.00:
FIRST( ITEM_NAME, ITEM_PRICE > 10 )
ITEM_NAME
ITEM_PRICE
Flashlight
35.00
Navigation Compass
8.05
Regulator System
150.00
Flashlight
29.00
Depth/Pressure Gauge
88.00
Flashlight
31.00
RETURN VALUE:
  Flashlight
The following expression returns the first value in the ITEM_NAME port with a price greater than $40.00:
FIRST( ITEM_NAME, ITEM_PRICE > 40 )
ITEM_NAME
ITEM_PRICE
Flashlight
35.00
Navigation Compass
8.05
Regulator System
150.00
Flashlight
29.00
Depth/Pressure Gauge
88.00
Flashlight
31.00
RETURN VALUE:
  Regulator System