first(X;Y)
Returns a string consisting of the first number of characters of a given string.
Syntax
first(X;Y)
Input
Argument | Type | Description |
---|---|---|
X |
text | The string on which to apply the function A scalar value or the name of a column |
Y |
integer | The number of characters to extract from X |
Return Value
Returns a text string comprised of the first Y
characters of
X
.
If X
is N/A, the result is Y
blank characters.
Sample Usage
value |
number |
first(value;number) |
---|---|---|
'banana' | 3 | 'ban' |
'banana' | 4 | 'bana' |
'banana' | 2 | 'ba' |
Example
In the "Product Master" table (pub.demo.retail.prod), you can extract
the substrings consisting of the first three characters of the department descriptions. To
do this, create a computed column and apply the first(X;Y)
function to the
deptdesc
column.
<base table="pub.demo.retail.prod"/> <willbe name="example" value="first(deptdesc;3)"/> <colord cols="deptdesc,example"/>
The results are the first three characters of the values in the deptdesc
column.
Additional Information
- This function does not work with Unicode (UTF-8) strings.
- For a Unicode-compliant alternative, consider
strextract(X;P;N)
.