Why has the lette ’m’ special role in following query? I tried to create a TRIM functions and I am stuck with it. Or: what is the differnce when I query from the dual and another table.
E.g.
I created a table with one column and two values (’adam’ and ’apperda’)
create table x
(col1 varchar2(20));
insert into x values ('adam');
insert into x values ('apperda');
Then I select the TRIM(TRAILING… ) and the RTRIM as follows:
select
col1,
trim(trailing 'am' from col1) traling,
rtrim(col1, 'am') rtim
from x;
And the result: ’ad’ and ’apperd’
COL1 TRALING RTIM
-------------------- -------------------- --------------------
adam ad ad
apperda apperd apperd
I don’t understand why apperd
turns up in the result… It should be an error message, shouldn’t it: ORA-30001: trim set should have only one character?
I tried two other selects:
Removed the trim(trailing…) part of the select.
select col1, trim(trailing 'am' from col1) traling from x;
Select from dual
select trim(trailing 'am' from 'apperda'), from dual;
Both query give me the error message:
ORA-30001: trim set should have only one character
The plus row in a query provides plus information? Or how it is possible? And it is not just the a query question but seems the two data (adam
and apperda
) interact:
I create a simple query with apperda
and it show the error:
select
trim(trailing 'am' from 'apperda') traling,
rtrim('apperda', 'am') rtim
from dual
ORA-30001: trim set should have only one character
the core example (2018-07-05)
create table trims
(col varchar2(20));
insert into trims values ('dream');
select
trim(trailing 'am' from col)
rtrim(col, 'am')
from trims;
The first row in the select should give the error ORA-30001, because there are two characters in trim(trailing...). But the script runs:
TRIM(TRAILING'AM'FROMCOL) RTRIM(COL,'AM')
-----------------------------------------------
dre dre
And: it seems that the trim(trailin...) depends on the rtrim(...) - if you erase the rtrim(...), the error message appears as is should be.
select
trim(trailing 'am' from col)
--rtrim(col, 'am')
from trims;
`ORA-30001: trim set should have only one character`