with an external table, the 21st century way to load data - we can do this.
with sqlldr, the 20th century legacy data loading tool for old people - you cannot really - you could fake it out with a trigger - but that is beyond a bad idea.
check it out:
ops$tkyte%ORA11GR2> create or replace directory my_dir as '/home/tkyte'
2 /
Directory created.
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> CREATE TABLE et
2 (
3 "EMPNO" VARCHAR2(10),
4 "ENAME" VARCHAR2(20),
5 "TELNOS" VARCHAR2(50),
6 "SAL" VARCHAR2(10)
7 )
8 ORGANIZATION external
9 (
10 TYPE oracle_loader
11 DEFAULT DIRECTORY MY_DIR
12 ACCESS PARAMETERS
13 (
14 RECORDS DELIMITED BY NEWLINE CHARACTERSET US7ASCII
15 BADFILE 'MY_DIR':'t.bad'
16 LOGFILE 't.log_xt'
17 READSIZE 1048576
18 FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' LDRTRIM
19 MISSING FIELD VALUES ARE NULL
20 REJECT ROWS WITH ALL NULL FIELDS
21 (
22 "EMPNO" CHAR(255)
23 TERMINATED BY "," OPTIONALLY ENCLOSED BY '"',
24 "ENAME" CHAR(255)
25 TERMINATED BY "," OPTIONALLY ENCLOSED BY '"',
26 "TELNOS" CHAR(1000)
27 TERMINATED BY "," OPTIONALLY ENCLOSED BY '"',
28 "SAL" CHAR(255)
29 TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
30 )
31 )
32 location
33 (
34 't.dat'
35 )
36 )
37 /
Table created.
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> select * from et;
EMPNO ENAME TELNOS SAL
---------- -------------------- -------------------------------------------------- ----------
12 smith 1234556@@1234567@@876556612 1200
14 John 1234@@4567@@56789@@12345@@45778@@34566@@23456 1345
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> select empno, ename, sal, i,
2 substr( tnos, instr( tnos, '@@', 1, i )+2, instr( tnos, '@@', 1, i+1 )-instr( tnos, '@@', 1, i) - 2 ) tno
3 from (
4 select to_number(et.empno) empno,
5 et.ename,
6 to_number(et.sal) sal,
7 column_value i,
8 '@@'||et.telnos||'@@' tnos
9 from et,
10 table( cast( multiset( select level
11 from dual
12 connect by level <= (length(et.telnos)-length(replace(et.telnos,'@@','')))/2+1 )
13 as sys.odciNumberList ) )
14 )
15 /
EMPNO ENAME SAL I TNO
---------- -------------------- ---------- ---------- --------------------
12 smith 1200 1 1234556
12 smith 1200 2 1234567
12 smith 1200 3 876556612
14 John 1345 1 1234
14 John 1345 2 4567
14 John 1345 3 56789
14 John 1345 4 12345
14 John 1345 5 45778
14 John 1345 6 34566
14 John 1345 7 23456
10 rows selected.
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> create table emp ( empno number primary key, ename varchar2(10), sal number );
Table created.
ops$tkyte%ORA11GR2> create table emp_contact( empno number references emp, phone_no number );
Table created.
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> insert all
2 when (i = 1) then into emp (empno,ename,sal) values (empno,ename,sal)
3 when (i > 0) then into emp_contact(empno,phone_no) values (empno,tno)
4 select empno, ename, sal, i,
5 substr( tnos, instr( tnos, '@@', 1, i )+2, instr( tnos, '@@', 1, i+1 )-instr( tnos, '@@', 1, i) - 2 ) tno
6 from (
7 select to_number(et.empno) empno,
8 et.ename,
9 to_number(et.sal) sal,
10 column_value i,
11 '@@'||et.telnos||'@@' tnos
12 from et,
13 table( cast( multiset( select level
14 from dual
15 connect by level <= (length(et.telnos)-length(replace(et.telnos,'@@','')))/2+1 )
16 as sys.odciNumberList ) )
17 )
18 /
12 rows created.
ops$tkyte%ORA11GR2>
ops$tkyte%ORA11GR2> select * from emp;
EMPNO ENAME SAL
---------- ---------- ----------
12 smith 1200
14 John 1345
ops$tkyte%ORA11GR2> select * from emp_contact;
EMPNO PHONE_NO
---------- ----------
12 1234556
12 1234567
12 876556612
14 1234
14 4567
14 56789
14 12345
14 45778
14 34566
14 23456
10 rows selected.