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

Col2 Function

Returns the character position following the substring specified in the most recently executed Field function.

Syntax

Col2 ( )

Remarks

The character position is returned as a number. The returned value is local to the routine executing the Field function. The value of Col2 in the routine is initialized as 0. When control is returned to the calling program, the saved value of Col2 is restored.

Col2 returns a value of 0 if:

Examples

The Field function in the following example returns substring "CCC". Col2 ( ) returns 12, the position that the delimiter (/) would have occupied following CCC if the end of the string had not been encountered.

* Extract third "/"-delimited field.
SubString = Field("AAA/BBB/CCC", "/" ,3)
Position = Col2()       ;* returns end of string in fact

In the following example, the Field function returns a substring of two fields with the delimiter (.) that separates them: 4.5. Col2 ( ) returns 10, the position of the delimiter that follows 5.

* Get fourth and fifth "."-delimited fields.
SubString = Field("1.2.3.4.5.6", ".", 4, 2)
Position = Col2()      ;* get position of delimiter

In the next example, Field returns the whole string, because the delimiter (.) is not found. Col2 ( ) returns 6, the position after the last character of the string.

* Attempts to first get first "."-delimited field, 
* but fails.
SubString = Field("9*8*7", ".", 1)
Position = Col2()        ;* returns length of string + 1

In the next example, Field returns an empty string, because there is no tenth occurrence of the substring in the string. Col2 ( ) returns 0 because the substring was not found.

* Attempts to first get tenth "."-delimited 
* field, but fails.
SubString = Field("9*8*7*6*5*4", "*", 10)
Position = Col2               ;* returns 0

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

Update timestamp Last updated: 2010-09-30