select ltrim('PREPROCESSINGLIST_AOD', 'PREPROCESSINGLIST_') as node_code from dual;
The expected result is AOD, but when I run by changing the first string then getting unexpected behavior.
Below are the trails I tried and run by changing the character after _ like BOD, COD...ZOD and below is weird result.
When AOD Result==> AOD
When BOD Result==> BOD
When COD Result==> D
When EOD Result==> D
When FOD Result==> FOD
When GOD Result==> D
When HOD Result==> HOD
When IOD Result==> D
When JOD Result==> JOD
When KOD Result==> KOD
When LOD Result==> D
When MOD Result==> MOD
When NOD Result==> D
When OOD Result==> D
When POD Result==> D
When QOD Result==> QOD
When ROD Result==> D
When SOD Result==> D
When TOD Result==> D
When UOD Result==> UOD
When VOD Result==> VOD
When WOD Result==> WOD
When XOD Result==> XOD
When YOD Result==> YOD
When ZOD Result==> ZOD
And... My question why is this weird behavior?
It isn't weird behavior. It is documented behavior.
According to the documentation of LTRIM:
So the second parameter, though in a string type, is not a string as such, it is a set of characters to trim away.
So this:
will end up returning
Dbecause bothCandOis inPREPROCESSINGLIST_:_AOD, however,Ais not in the set so the trimming stops there.If you test you can see that you get exactly the same behavior from this:
This should be the same characters as in
PREPROCESSINGLIST_.