Reputation: 451
SELECT RTRIM('CO_CODE_VALUE', 'VALUE') FROM dual;
Result is CO_CODE_ But
SELECT RTRIM('CO_CODE_VALUE', '_VALUE') FROM dual;
Result is CO_COD
Does anybody know why?
Upvotes: 0
Views: 68
Reputation: 22959
From Oracle documentation:
RTRIM removes from the right end of char all of the characters that appear in set.
That is, in your case, it starts from the right and removes all the characters in the set '_VALUE', not the string '_VALUE'. For example:
select rtrim('EEEXEEEEEEE', '_VALUE') from dual
gives
EEEX
Because it starts from the right, and removes all the characters in ('V', 'A', 'L', 'U', 'E', 'S', '_')
, that is all the occurences of 'E'
going backward until it finds a character not in the set (the 'X'
)
Upvotes: 3