PDA

View Full Version : SQLLDR reusing column records


Jim
09-05-2003, 09:08 AM
I have a file that contains several records where each field is
delimited by commas:

'field1','field2','field3','field4',

ie:
'aaa','b','c','d',
'aaaaaaaa',bbb','','ffff',

I would like to use sqlldr to load the file into a table placing each
record's field in the following fashion:

LOAD DATA
APPEND
INTO TABLE mytable
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
(
column1 field1
column2 field2
column3 field3
column4 field2
column5 field2
column6 field3
)

Thank you

TurkBear
09-05-2003, 10:12 AM
shija03@hotmail.com (Jim) wrote:
I have a file that contains several records where each field isdelimited by commas: 'field1','field2','field3','field4',ie: 'aaa','b','c','d', 'aaaaaaaa',bbb','','ffff',I would like to use sqlldr to load the file into a table placing eachrecord's field in the following fashion:LOAD DATAAPPENDINTO TABLE mytableFIELDS TERMINATED BY ","TRAILING NULLCOLS( column1 field1 column2 field2 column3 field3 column4 field2 column5 field2 column6 field3)Thank you
You can try ( but I do not think you really want to do this) :

LOAD DATA
APPEND
INTO TABLE mytable
FIELDS TERMINATED BY ","
TRAILING NULLCOLS
(
field1,
field2,
field3,
field2,
field2,
field3, etc
)
Basically you name the field into which each value in each row of the delimited file should go .
Now, as to why not to do this:
Each subsequent reference to field2 after the first one , for instance, will replace the data previously loaded with the new
value as long as the same row of input data is being read and this method may not even work - I've never tried it..

If what you really want to do is to split a single line of input data into more than one record, that requires a different
approach and may not be possible..

Daniel Morgan
09-05-2003, 05:56 PM
Turkbear wrote:
shija03@hotmail.com (Jim) wrote:I have a file that contains several records where each field isdelimited by commas: 'field1','field2','field3','field4',ie: 'aaa','b','c','d', 'aaaaaaaa',bbb','','ffff',I would like to use sqlldr to load the file into a table placing eachrecord's field in the following fashion:LOAD DATAAPPENDINTO TABLE mytableFIELDS TERMINATED BY ","TRAILING NULLCOLS( column1 field1 column2 field2 column3 field3 column4 field2 column5 field2 column6 field3)Thank youYou can try ( but I do not think you really want to do this) :LOAD DATAAPPENDINTO TABLE mytableFIELDS TERMINATED BY ","TRAILING NULLCOLS( field1, field2, field3, field2, field2, field3, etc)Basically you name the field into which each value in each row of the delimited file should go .Now, as to why not to do this:Each subsequent reference to field2 after the first one , for instance, will replace the data previously loaded with the newvalue as long as the same row of input data is being read and this method may not even work - I've never tried it..If what you really want to do is to split a single line of input data into more than one record, that requires a differentapproach and may not be possible..
Turkbear's method should work. If not ... load to a staging table and
then use a simple INSERT statement to move the data.

--
Daniel Morgan
http://www.outreach.washington.edu/ext/certificates/oad/oad_crs.asp
http://www.outreach.washington.edu/ext/certificates/aoa/aoa_crs.asp
damorgan@x.washington.edu
(replace 'x' with a 'u' to reply)


MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service