Oracle trim does not drop white space characters
Problem Background:
A business registration number is a normal problem that trim can solve, but in this case, trim is different from what we see with the naked eye, that is, there is an extra character.
Analyze the problem:
In order to reproduce the problem, the following simulation creates a 12345 plus a special character (hypothetical blank)
Select concat ('20140901', chr (9) as xx from dual)
1. Check the length.
SELECT length (concat ('20140901', chr (9) as xx from dual
I felt free characters in the above section (6! = 7)
Try trim.
SELECT length (xx), length (trim (xx ))
From (
Select concat ('20140901', chr (9) as xx from dual)
It is found that trim cannot be dropped or the length is 7.
OK. We use the dump function to learn about the data type storage method of oracle.
Select dump (xx) from (select concat ('20140901', chr (9) as xx from dual)
The above type = 1 indicates that the value type is VARCHAR2.
Len indicates the number of bytes occupied by the value, which is 7 bytes long.
49,50, 51,52, 53,54, 9
49,50, 51,52, 53,54 for an ascii code of 123456
The ascii value of 9 is a horizontal positioning symbol.
But how did this 9 get in? Ctrl + tab!
Solve the problem: update it directly.