Home » RDBMS Server » Server Utilities » loading data into two tables from single input file
loading data into two tables from single input file [message #199162] |
Fri, 20 October 2006 12:51 |
roopla
Messages: 52 Registered: May 2006
|
Member |
|
|
Is it possible to load into two different tables using sql loader.
I have a input file which has header record and detail records. I want header record go into different table and details go into other table.
Please advice
|
|
|
|
|
|
Re: loading data into two tables from single input file [message #199168 is a reply to message #199165] |
Fri, 20 October 2006 13:31 |
roopla
Messages: 52 Registered: May 2006
|
Member |
|
|
First and last records should go to controltb table
and rest should go to details table
Detail Table
create table details (rtyp varchar(10),sttpe varchar(10),st varchar(2),stdt varchar(30),stind varchar(2))
control Table
create table controltb (rtyp varchar(10),hdtpe varchar(10),stdate date,stdt varchar(30))
Datafile
00,HDR,09/28/2006,00000000007
66,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
67,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
68,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
69,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
10,TRL,09/28/2006,00000000007
|
|
|
|
|
|
|
Re: loading data into two tables from single input file [message #199176 is a reply to message #199175] |
Fri, 20 October 2006 14:59 |
|
Mahesh Rajendran
Messages: 10708 Registered: March 2002 Location: oracleDocoVille
|
Senior Member Account Moderator |
|
|
Anyhow, you asked and awk is an overkill
oracle@mutation#cat sample.data
00,HDR,09/28/2006,00000000007
66,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
67,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
68,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
69,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
10,TRL,09/28/2006,00000000007
oracle@mutation#
oracle@mutation#
oracle@mutation#head -1 sample.data > headtail.data
oracle@mutation#tail -1 sample.data >> headtail.data
oracle@mutation#
oracle@mutation#cat sample.data | grep -v `head -1 sample.data` | grep -v `tail -1 sample.data` > detail.data
oracle@mutation#
oracle@mutation#cat headtail.data
00,HDR,09/28/2006,00000000007
10,TRL,09/28/2006,00000000007
oracle@mutation#
oracle@mutation#cat detail.data
66,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
67,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
68,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
69,MDVW,VA,VAFBF0,M0049-001-000-000-001,Y
oracle@mutation#
[Updated on: Fri, 20 October 2006 15:00] Report message to a moderator
|
|
|
|
|
|
|
Goto Forum:
Current Time: Wed Dec 25 23:48:14 CST 2024
|