Home » RDBMS Server » Server Utilities » Help with sql loader
Help with sql loader [message #336667] |
Mon, 28 July 2008 10:42 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
simulcop
Messages: 5 Registered: July 2008
|
Junior Member |
|
|
Hi all, need help, i have a csv file with this structure:
headerfield1,headerfield2,headerfield3,headerfield4
detail1field1,detail1field2,detail1field3,detail1field4,detail1field5
detail2field1,detail2field2,detail2field3,detail2field4,detail2field5
detail3field1,detail3field2,detail3field3,detail3field4,detail3field5
detail4field1,detail4field2,detail4field3,detail4field4,detail4field5
detail5field1,detail5field2,detail5field3,detail5field4,detail5field5
detail6field1,detail6field2,detail6field3,detail6field4,detail6field5
.
.
.
detailnfield1,detailnfield2,detailnfield3,detailnfield4,detailnfield5
It's a file that have information about purchasing order, where the first line is the header of the order and the other lines are the items of the order.
The idea is to load a table with the next structure using sqlloader:
headerfield1,headerfield2,headerfield3,headerfield4,detail1field1,detail1field2,detail1field3,detail1field4,detail1field5
headerfield1,headerfield2,headerfield3,headerfield4,detail2field1,detail2field2,detail2field3,detail2field4,detail2field5
headerfield1,headerfield2,headerfield3,headerfield4,detail3field1,detail3field2,detail3field3,detail3field4,detail3field5
headerfield1,headerfield2,headerfield3,headerfield4,detail4field1,detail4field2,detail4field3,detail4field4,detail4field5
headerfield1,headerfield2,headerfield3,headerfield4,detail5field1,detail5field2,detail5field3,detail5field4,detail5field5
headerfield1,headerfield2,headerfield3,headerfield4,detail6field1,detail6field2,detail6field3,detail6field4,detail6field5
.
.
.
headerfield1,headerfield2,headerfield3,headerfield4,detailnfield1,detailnfield2,detailnfield3,detailnfield4,detailnfield5
Thanks in advanced for your helpfull advice
Regards
Javier R.
|
|
|
|
Re: Help with sql loader [message #336669 is a reply to message #336667] |
Mon, 28 July 2008 10:55 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
simulcop
Messages: 5 Registered: July 2008
|
Junior Member |
|
|
Anacedent, thanks for reply.
That's the easy part, in a file i have only one header all the item lines belong to the same header. In other words, i have only one order for each csv file.
Thanks again
regards
Javier R.
|
|
|
|
|
|
Re: Help with sql loader [message #336677 is a reply to message #336667] |
Mon, 28 July 2008 12:05 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](http://www.orafaq.com/forum/images/custom_avatars/136107.jpg) |
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
[oracle@amo1test tmp]$ cat clever.sh
head -1 sample.dat > header1.raw
HEAD=`cat header1.raw`
export HEAD
echo "${HEAD}"
rm sample.new
awk -v var1=$HEAD '{print var1","$1}' <sample.dat > sample.new
cat sample.new
[oracle@amo1test tmp]$ ./clever.sh
headerfield1,headerfield2,headerfield3,headerfield4
headerfield1,headerfield2,headerfield3,headerfield4,headerfield1,headerfield2,headerfield3,headerfield4
headerfield1,headerfield2,headerfield3,headerfield4,detail1field1,detail1field2,detail1field3,detail1field4,detail1field5
headerfield1,headerfield2,headerfield3,headerfield4,detail2field1,detail2field2,detail2field3,detail2field4,detail2field5
headerfield1,headerfield2,headerfield3,headerfield4,detail3field1,detail3field2,detail3field3,detail3field4,detail3field5
headerfield1,headerfield2,headerfield3,headerfield4,detail4field1,detail4field2,detail4field3,detail4field4,detail4field5
headerfield1,headerfield2,headerfield3,headerfield4,detail5field1,detail5field2,detail5field3,detail5field4,detail5field5
headerfield1,headerfield2,headerfield3,headerfield4,detail6field1,detail6field2,detail6field3,detail6field4,detail6field5
[oracle@amo1test tmp]$
|
|
|
|
|
|
Re: Help with sql loader [message #337319 is a reply to message #336677] |
Wed, 30 July 2008 09:49 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
simulcop
Messages: 5 Registered: July 2008
|
Junior Member |
|
|
How can i do this with a batch (.bat) file on windows, it's possible?
Thanks for your help.
Javier R.
anacedent wrote on Mon, 28 July 2008 12:05 |
[oracle@amo1test tmp]$ cat clever.sh
head -1 sample.dat > header1.raw
HEAD=`cat header1.raw`
export HEAD
echo "${HEAD}"
rm sample.new
awk -v var1=$HEAD '{print var1","$1}' <sample.dat > sample.new
cat sample.new
[oracle@amo1test tmp]$ ./clever.sh
headerfield1,headerfield2,headerfield3,headerfield4
headerfield1,headerfield2,headerfield3,headerfield4,headerfield1,headerfield2,headerfield3,headerfield4
headerfield1,headerfield2,headerfield3,headerfield4,detail1field1,detail1field2,detail1field3,detail1field4,detail1field5
headerfield1,headerfield2,headerfield3,headerfield4,detail2field1,detail2field2,detail2field3,detail2field4,detail2field5
headerfield1,headerfield2,headerfield3,headerfield4,detail3field1,detail3field2,detail3field3,detail3field4,detail3field5
headerfield1,headerfield2,headerfield3,headerfield4,detail4field1,detail4field2,detail4field3,detail4field4,detail4field5
headerfield1,headerfield2,headerfield3,headerfield4,detail5field1,detail5field2,detail5field3,detail5field4,detail5field5
headerfield1,headerfield2,headerfield3,headerfield4,detail6field1,detail6field2,detail6field3,detail6field4,detail6field5
[oracle@amo1test tmp]$
|
|
|
|
|
|
Goto Forum:
Current Time: Thu Aug 29 15:07:20 CDT 2024
|