In the Oracle DB there is a table that stores "DIN"
s attribute (VARCHAR2(1200 BYTE)
), see a table/image below.
Each string follows the DIN 1421 pattern.
+------------------+
| DIN |
+------------------+
| 0004.01.03.00.00 |
| 0006.06.00.00.00 |
| 0002.02.01.00.00 |
| 0002.02.02.00.00 |
| 0349.00.00.00.00 |
| 0004.00.01.00.00 |
| 0001.05.20.10.30 |
| ... |
+------------------+
Now, I am trying to convert this string to more human-readable format, i.e.
0004.01.03.00.00 → 4.1.3
0006.06.00.00.00 → 6.6
0002.02.01.00.00 → 2.2.1
0002.02.02.00.00 → 2.2.2
0349.00.00.00.00 → 349
0004.00.01.00.00 → 4.0.1
0001.05.20.10.30 → 1.5.20.10.30
How can I achieve this?
I can imagine myself working with the combination of to_number()
and substr()
functions and applying each time the CASE
expression. But there must be more efficient and meaningful solution, is not it?