Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Aug 2007
Posts: 26
use SQL loader to dump a fixed length file in to DB

consider a fixed length file

12345abcd8901
12345abcd7777
12345njdu8888
12345hdku8388


i would like to dump it in to oracle DB using sql loader
12345 in to first coloumn
abcd in to second coloumn
8901 in to 3rd coloumn
Sponsored Links
  #2 (permalink)  
Old 10-10-2007
dennis.jacob's Avatar
dj - the student
 

Join Date: Feb 2007
Location: Singapore/Cochin
Posts: 819
Two steps

1.Make a csv file


Code:
awk 'BEGIN{FIELDWIDTHS = "5 4 4"}; {print $1","$2","$3;}' filename

2.
Code:
load data
          infile 'filename.csv'
		  into table tablename
          fields terminated by ","

  #3 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Jun 2004
Posts: 152
You can edit the control file of the sqlloader by the following:


Code:
LOAD DATA
INFILE <data_file_path_and_name>
INTO TABLE <table_name> (
<column_name> POSITION(<integer>:<integer>) <data_type>,
<column_name> POSITION(<integer>:<integer>) <data_type>,
<column_name> POSITION(<integer>:<integer>) <data_type>)

I.e:
LOAD DATA
   INFILE /tmp/load_data.dat
   INTO TABLE t1
     (col1 POSITION(1:5) ,
      col2 POSITION(6:9) , 
      col3 POSITION(10:13))

Regards,
Nir
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What the command to find out the record length of a fixed length file? tranq01 UNIX for Dummies Questions & Answers 9 12-04-2008 04:04 PM
how to convert Fixed length file to delimited file. satyam_sat Shell Programming and Scripting 7 04-03-2008 03:41 AM
Manipulating a fixed length file w/o PERL dabear Shell Programming and Scripting 4 03-31-2008 05:33 PM
convert XML file into Text file(fixed length) ram2s2001 Shell Programming and Scripting 0 11-03-2005 01:28 AM
creating a fixed length output from a variable length input r1500 Shell Programming and Scripting 2 12-03-2003 01:09 PM



All times are GMT -4. The time now is 05:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0