Oracle ..
Of course it is sometimes difficult ...
select LPAD (ltrim ('\u0026lt;string>', '0 '), 4, '0') from dual
What does this SQL query?
Well .. takes the string that I put in the place of \u0026lt;string>, removes all the zeros that are left and then makes it again to the left padding with zeros, until a string of 4 characters.
For example: if
STRING is 0000000000123, the result is 0123
if STRING is 023, the result is 0023
if STRING is 0000000, the result is 0000
ERROR! Since the second
Oracle, there is no 'difference between an empty string ('') and a \u0026lt;null> the query result is null ...
grrrrr ...
the correct version then:
select LPAD (LTRIM (NVL ('\u0026lt;string>', '0 '), '0'), 4, '0 ') from dual
0 comments:
Post a Comment