My colleague had some trouble with the data with embedded line breaks before ending the recordes, and ask me if I could help. I could not help to jump on my "first love" :)) special feeling about sqlloader:))
sqlloader offer two possibilities : - courtesy to http://gerardnico.com/wiki/!
- if you have a special character at the end of each line: the stream record format
- if you don't have a special character at the end of each line: the CONTINUEIF statement.
Here is the sample data for us:
"100045678","address is
super street
18999 Edmonton Alberta
T6R4Y3" ............................................
"2","the degree is MBA
UT
1998" ............................................
"100045678","address is
super street
18999 Edmonton Alberta
T6R4Y3" ............................................
"2","the degree is MBA
UT
1998" ............................................
The each field inside data looks enclosed with double quotes "xxx", so we could simple add the CONTINUEIF to control the end of records.
From Oracle:
Using CONTINUEIF to Assemble Logical Records
UseCONTINUEIF
if the number of physical records to be combined varies. The CONTINUEIF
clause is followed by a condition that is evaluated for each physical record, as it is read. For example, two records might be combined if a pound sign (#) were in byte position 80 of the first record. If any other character were there, the second record would not be added to the first.The full syntax for
CONTINUEIF
adds even more flexibility:Table 8-2 describes the parameters for the
CONTINUEIF
clause.Therefore we ask the loader to continue the record if see a break line not followed by a double quote, which means it's not the end of records!
LOAD DATA
INFILE 'giftdata.dat'
CONTINUEIF LAST != '"'
INTO TABLE conversion
APPEND
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
(
"ID",
"DESCRIPTION" CHAR(500)
)
Cheers!