Does anyone know why these:
SELECT RTRIM('123R_CLUSTER', '_CLUSTER') -- should give '123R'
SELECT RTRIM('123S_CLUSTER', '_CLUSTER') -- should give '123S'
SELECT RTRIM('123T_CLUSTER', '_CLUSTER') -- should give '123T'
SELECT RTRIM('123U_CLUSTER', '_CLUSTER') -- should give '123U'
The documentation is quite clear:
The Oracle/PLSQL RTRIM function removes all specified characters from the right-hand side of a string.
So it doesn't remove the string
_CLUSTER at the end of your string - it removes characters until there is one that isn't _, C, L, U, S, T, E or R. Since your postfixes are R/S/T/U, they also match the
rtrim condition, and are removed. As would
123S_SLURTE, for example.
As an easier to understand example,
rtrim('LK_123aababaabbbababbaa', 'ab') // returns LK_123
rtrim simply isn't the tool for the job at hand :)