Caché SQL Reference
A scalar string function that returns a character string in reverse character order.
||The string expression to be reversed. The expression can be the name of a column, a string literal, a numeric, or the result of another scalar function, where the underlying data type can be represented as any character type (such as CHAR or VARCHAR).
with its character order reversed. For example, 'Hello World!' is returned as '!dlroW olleH'. This is a simple string-order reversal, with no additional processing.
The string returned is data type VARCHAR, regardless of the data type of the input value. Numbers are converted to canonical form, numeric strings are not converted to canonical form before reversing.
Leading and trailing blanks are unaffected by reversing.
Reversing a NULL value results in a NULL.
always returns a VARCHAR string, some types of data become invalid when reversed:
A reversed list is no longer a valid list and cannot be converted from storage format to display format.
A reversed date is no longer a valid date, and cannot be converted from storage format to display format.
The following example reverses the Name field values. In this case, this results in names sorted by middle initial:
SELECT Name,REVERSE(Name) AS RevName
ORDER BY RevName
The following example reverses a number and a numeric string:
SELECT REVERSE(+007.10) AS RevNum,
REVERSE('+007.10') AS RevNumStr
The following Embedded SQL example reverses a $DOUBLE number:
&sql(SELECT REVERSE(:dnum) INTO :drevnum)
The following example shows what happens when you reverse a list:
SELECT FavoriteColors,REVERSE(FavoriteColors) AS RevColors
The following example shows what happens when you reverse a date:
SELECT DOB,%INTERNAL(DOB) AS IntDOB,REVERSE(DOB) AS RevDOB