Man, storing times as 24hr numbers is a bad idea. But anyway, the first issue is ambiguity, ie
10101
Is that 10am or 1am ?...So for the sake of this discussion we'll assume the last 4 digits are *always* mins and secs.
Now you didnt specify if you want the output to be a date or a string, so we'll look at each:
We'll start with a number, then convert to a string, and then either use date or string functions depending on what you're after:
SQL> variable x number
SQL> exec :x := 123456
PL/SQL procedure successfully completed.
SQL> select to_char(:x) from dual;
TO_CHAR(:X)
----------------------------------------
123456
1 row selected.
SQL> select substr(to_char(:x),-4) from dual;
SUBSTR(TO_CHAR(:
----------------
3456
1 row selected.
SQL> select substr(to_char(:x),1,length(to_char(:x))-4) from dual;
SUBSTR(TO_CHAR(:X),1,LENGTH(TO_CHAR(:X))-4)
------------------------------------------------------------------------------------
12
1 row selected.
SQL> select to_date(substr(to_char(:x),1,length(to_char(:x))-4)||':'||substr(to_char(:x),-4),'HH24:MISS') from dual;
TO_DATE(SUBSTR(TO_C
-------------------
01/08/2017 12:34:56
SQL> select lpad(substr(to_char(:x),1,length(to_char(:x))-4),2,'0')||':'||
2 substr(to_char(:x),-4,2)||':'||
3 substr(to_char(:x),-2)
4 from dual;
LPAD(SUBSTR(TO_CHAR(:X),1,
--------------------------
12:34:56