RTRIM - connect_cdc_sqdata - Latest

Connect CDC (SQData) Apply engine

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (SQData)
Version
Latest
Language
English
Product name
Connect CDC (SQData)
Title
Connect CDC (SQData) Apply engine
Copyright
2024
First publish date
2000
ft:lastEdition
2024-07-30
ft:lastPublication
2024-07-30T20:19:56.898694

RTRIM examines a data string from right to left and compares the contents to an exclusion character string. If a match is found between data string and the exclusion character string, the RTRIM function removes the characters which match the exclusion character string. RTRIM continues until the first non-matching character is found. It also provides flexibility regarding the method of comparison by specifying either the ANY or MATCH parameter. Note that for single character exclusion strings, ANY and MATCH will return the same results. A common use of RTRIM is to remove spaces from the right side of a string.

Category

String

Syntax

RTRIM(data_string, trim_character_string, 'ANY' | 'MATCH' )

Parameters and Descriptions

Parameter Description
data_string The data string in character format. The data string can be a field from a source datastore, a variable, a constant or the result of another Function.
trim_character_string

One (1) or more characters that specify the characters to exclude from the right hand side of the data string. Exclusion characters may be a field of a source datastore, a literal value or the output of another Function.

ANY | MATCH
Denotes the type of matching from the right side of a source data string based on the contents of the exclusion character string. Note that these parameters must be enclosed in single quotes.
  • ANY Indicates that partial matches to the exclusion sting are allowed. ANY is most useful when the exclusion string is more than one character. As RTRIM scans the string from right to left, the current character will be removed if it appears anywhere in the exclusion string. Thus, the exclusion string should be thought of as a list of characters which have no order. RTRIM will stop scanning when it encounters the first non-matching character. All characters before this point will be removed.

  • MATCH Indicates that an exact match to the exclusion string must be made. Starting on the right, RTRIM compares the last character in the exclusion string to the current character in the data string, then the next character of the exclusion string to the next character of the data string to see if it matches and so on, until a non-matching character is found. If a full match is found, it is removed from the data string and RTRIM continues scaning the data string to see if there is another exact match to remove until all contiguous repeating instances of the exclusion string have been removed from the data string.
    Note: This parameter must be enclosed in single quotes.

Example

RTRIM with data string as a datastore field, literal, variable, output of another Function.
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'D', 'MATCH')
TARGET.FIELD = RTRIM('ABCD', 'D', 'MATCH')
TARGET.FIELD = RTRIM(VARIABLE, 'D', 'MATCH')
TARGET.FIELD = RTRIM(FUNCTION(SOURCE.FIELD), 'D', 'MATCH')

--Assuming SOURCE.FIELD = 'ABCD', VARIABLE = 'ABCD', and the result of

--FUNCTION(SOURCE.FIELD) = 'ABCD' the results would be 'ABC' for all cases.

RTRIM with the exclusion string as a datastore field, literal, variable, output of another Function.
TARGET.FIELD = RTRIM('ABCD', SOURCE.FIELD, 'MATCH')
TARGET.FIELD = RTRIM('ABCD', 'D', 'MATCH')
TARGET.FIELD = RTRIM('ABCD', VARIABLE, 'MATCH')
TARGET.FIELD = RTRIM('ABCD', FUNCTION(SOURCE.FIELD), 'MATCH')

--Assuming SOURCE.FIELD = 'D', VARIABLE = 'D', and the result of

--FUNCTION(SOURCE.FIELD) = 'D' the results would be 'ABC' for all cases.

RTRIM with one character returns the same result for both MATCH and ANY keywords
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'D', 'MATCH')
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'D', 'ANY')

--Assuming SOURCE.FIELD = 'ABCD', the result would be 'ABC' for either case.

RTRIM will remove multiple contiguous instances of a match.
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'A', 'MATCH')
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'A', 'ANY')

--Assuming SOURCE.FIELD = 'BCDAAA', the result would be 'BCD' for either case.

RTRIM will remove multiple contiguous instances of a match
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'AB', 'MATCH')

--Assuming SOURCE.FIELD = 'CDABAB', the result would be 'CD'.

RTRIM with ANY keyword. Order does not matter
TARGET.FIELD = RTRIM(SOURCE.FIELD, 'ABC', 'ANY')

--Assuming SOURCE.FIELD = 'ADCABC', the result would be 'AD'.