Information icon IBM InfoSphere DataStage and InfoSphere QualityStage, Version 8.5
space Feedback

Field Function

Returns delimited substrings in a string.

Syntax

Field (string, delimiter, instance [ ,number] )

string is the string containing the substring. If string is a null value, null is returned.

delimiter is the character that delimits the substring. If delimiter is an empty string, string is returned. If string does not contain delimiter, an empty string is returned unless instance is 1, in which case string is returned. If delimiter is a null value, a runtime error occurs. If more than one substring is returned, delimiters are returned with the substrings.

instance specifies which instance of delimiter terminates the substring. If instance is less than 1, 1 is assumed. If string does not contain instance, an empty string is returned. If instance is a null value, a runtime error occurs.

number specifies the number of delimited substrings to return. If number is an empty string or less than 1, 1 is assumed. If number is a null value, a runtime error occurs.

Examples

In the following example the variable MyString is set to the data between the third and fourth occurrences of the delimiter "#":

MyString = Field("###DHHH#KK","#", 4)  ;* returns "DHHH"

In the following example SubString is set to "" since the delimiter "/" does not appear in the string:

MyString = "London+0171+NW2+AZ"
SubString = Field(Mystring, "/", 1)    ;* returns ""

In the following example SubString is set to "0171+NW2" since two fields were requested using the delimiter "+" (the second and third fields):

MyString = "London+0171+NW2+AZ"
SubString = Field(Mystring, "+", 2, 2) 
* returns "0171+NW2"

PDFThis topic is also in the IBM InfoSphere DataStage Server Job Developer's Guide.

Update timestamp Last updated: 2010-09-30