sql - Oracle RTRIM trims more than asked for -


does know why these:

select rtrim('123r_cluster', '_cluster') -- should give '123r'  dual; select rtrim('123s_cluster', '_cluster') -- should give '123s'  dual; select rtrim('123t_cluster', '_cluster') -- should give '123t' dual; select rtrim('123u_cluster', '_cluster') -- should give '123u' dual; 

return '123' instead of expected?

i'm on oracle database 12c enterprise edition release 12.1.0.2.0 - 64bit production.

the fun begins when try these:

  • replace 123 else (no change still wrong results, i.e. trims 1 character more),
  • replace "r" / "s" / "t" / "u" else, (works ok)
  • replace "_cluster" else, (works ok)
  • add after "_cluster" (no change).

the documentation quite clear:

the oracle/plsql rtrim function removes specified characters right-hand side of string.

so doesn't remove string _cluster @ end of string - removes characters until there 1 isn't _, c, l, u, s, t, e or r. since postfixes r/s/t/u, match rtrim condition, , removed. 123s_slurte, example.

as easier understand example,

rtrim('lk_123aababaabbbababbaa', 'ab') // returns lk_123 

rtrim isn't tool job @ hand :)


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -