String functions perform basic operations on strings obtained from various data sources.
All supported string functions are listed below:
concat-function, substring-function, starts-with-function, ends-with-function.
| • | <das:concat-function> - concatenates two or more input values into a resulting string. In the sample below FIRST_NAME and LAST_NAME fields |
are concatenated into a full name, separated by the space character.
<das:sql-data-source id="ds1" connection="con1" select="select * from emp">
<das:field id="fld1" name="ID"/>
<das:field id="fld2" name="FIRST_NAME"/>
<das:field id="fld3" name="LAST_NAME"/>
</das:sql-data-source>
<das:concat-function id="fct1">
<das:in-param src="fld2"/>
<das:in-param src="ret2"/>
<das:in-param src="fld3"/>
<das:return-value id="ret1"/>
</das:concat-function>
<das:const-function>
<das:const-return-value id="ret2" value=" " type="string"/>
</das:const-function>
| • | <das:substring-function> - returns a substring from an input value. This function must have three named parameters string, pos and size. |
According to the example above, a function that returns the first two characters of the FIRST_NAME field may look like this:
<das:substr-function>
<das:in-param name="string" src="fld2"/>
<das:in-param name="pos" src="pos_result"/>
<das:in-param name="size" src="size_result"/>
<das:return-value id="ret4"/>
</das:substr-function>
<das:const-function>
<das:const-return-value id="pos_result" value="0" type="int"/>
</das:const-function>
<das:const-function>
<das:const-return-value id="size_result" value="2" type="int"/>
</das:const-function>
| • | <das:contains-function> - returns true if a string obtained from an input value contains another string. This function must have two named parameters content and substring. Below, the contain-function returns true if the FIRST_NAME contains the 'Mary' string. |
<das:contains-function>
<das:in-param name="content" src="fld2"/>
<das:in-param name="substring" src="mary_id"/>
<das:return-value id="ret5"/>
</das:substr-function>
<das:const-function>
<das:const-return-value id="mary_id" value="Mary" type="string"/>
</das:const-function>
| • | <das:starts-with-function> and <das:ends-with-function> return true if a string obtained from an input value starts-with (ends-with) another string. This function must have two named parameters content and string. Below, the starts-with function returns true if the FIRST_NAME starts with the letter 'A'. |
<das:starts-with-function>
<das:in-param name="content" src="fld2"/>
<das:in-param name="substring" src="A_id"/>
<das:return-value id="ret6"/>
</das:starts-with-function>
<das:const-function>
<das:const-return-value id="A_id" value="A" type="string"/>
</das:const-function>