InterSystems IRIS Data Platform 2019.2  /  InterSystems SQL Reference  /  SQL Functions

InterSystems SQL Reference
Previous section           Next section
InterSystems: The power behind what matters   

A string function that returns a string with the trailing blanks removed.

{fn RTRIM(string-expression)}
string-expression A string expression, which can be the name of a column, a string literal, or the result of another scalar function, where the underlying data type can be represented as any character type (such as CHAR or VARCHAR).
RTRIM removes the trailing blanks from a string expression, and returns the string as type VARCHAR. If string-expression is NULL, RTRIM returns NULL. If string-expression is a string consisting entirely of blank spaces, RTRIM returns the empty string ('').
RTRIM leave leading blanks; to remove leading blanks, use LTRIM. To remove leading and/or trailing characters of any type, use TRIM. To pad a string with trailing blanks or other characters, use RPAD. To create a string of blanks, use SPACE.
Note that RTRIM can be used as an ODBC scalar function (with the curly brace syntax) or as an SQL general function.
The following Embedded SQL example removes the five trailing blanks from the string. It leaves the five leading blanks:
   SET a="     Test string with 5 leading and 5 trailing spaces.     "
   &sql(SELECT {fn RTRIM(:a)} INTO :b)
   IF SQLCODE'=0 {
     WRITE !,"Error code ",SQLCODE }
   ELSE {
     WRITE !,"Before RTRIM",!,"start:",a,":end"
     WRITE !,"After RTRIM",!,"start:",b,":end" }
Before RTRIM
start:     Test string with 5 leading and 5 trailing spaces.     :end
start:     Test string with 5 leading and 5 trailing spaces.:end
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-20 05:47:55