TamilPHP Code:10:20:08 SQL> select * from my_table ;
CODE_ID
------------------------------
G0DE-0-10047514
M0DF-1-10000281
T0DH-3-20500819
R0DJ-2-10603746
G0DY-0-20006783
G0DZ-0-20049734
G0E0-0-10004325
G0E1-0-10049593
A20T-0-EMS00038
D20T-0-EMS00039
S20T-0-EMS00041
M20T-0-EMS00234
12 rows selected.
SQL> select code_id,
(case
when ascii(substr(code_id,8,1))>= 48 and
ascii(substr(code_id,8,1)) <= 57 then
(substr(code_id,8,2)||'-'||to_char(to_number(substr(code_id,-6))))
else substr(code_id,-8)
end) newstr
from my_table;
CODE_ID NEWSTR
------------------------------ -------------------------------------------
G0DE-0-10047514 10-47514
M0DF-1-10000281 10-281
T0DH-3-20500819 20-500819
R0DJ-2-10603746 10-603746
G0DY-0-20006783 20-6783
G0DZ-0-20049734 20-49734
G0E0-0-10004325 10-4325
G0E1-0-10049593 10-49593
A20T-0-EMS00038 EMS00038
D20T-0-EMS00039 EMS00039
S20T-0-EMS00041 EMS00041
M20T-0-EMS00234 EMS00234
12 rows selected.
10:20:35 SQL>




Reply With Quote