Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Prasad.

Asked: May 16, 2017 - 8:11 pm UTC

Last updated: June 19, 2017 - 3:38 am UTC

Version: oracle 10.1.2

Viewed 1000+ times

You Asked

Hi,

I have data in the below format,how to load its without loosing double quite...

all columns enclosed in "" and separated by ~ , also last column has values with double quote and need to load with quote

"Jobid"~"Jobname"~"Status"~"Comment"
"Test1"~"Test1 Job"~"Complete"~"~"Job completed without any issues"
"Test2"~"Test2 Job"~"In-progress"~"~"Job has dependency with "test0" job status "
"Test3"~"Test3 Job"~"In-progress"~"~"Job will start from "Next weekFrdiay" "
"Test4"~"Test4 Job"~"Complete"~"~"Job completed without any issues"

and Connor said...

How about something like this

SQL> create table t (
  2  Jobid varchar2(20),
  3  Jobname varchar2(30),
  4  Status varchar2(30),
  5  Comments varchar2(30)
  6  );

Table created.

LOAD DATA
INFILE *
TRUNCATE 
INTO TABLE t
FIELDS TERMINATED BY "~" 
TRAILING NULLCOLS
(
Jobid "LTRIM(RTRIM(:Jobid,chr(34)),chr(34))",
Jobname "LTRIM(RTRIM(:Jobname,chr(34)),chr(34))",
Status "LTRIM(RTRIM(:Status,chr(34)),chr(34))",
Comments "LTRIM(RTRIM(:Comments,chr(34)),chr(34))"
)
BEGINDATA
"Test1"~"Test1 Job"~"Complete"~"Job completed without any issues"
"Test2"~"Test2 Job"~"In-progress"~"Job has dependency with "test0" job status "
"Test3"~"Test3 Job"~"In-progress"~"Job will start from "Next weekFrdiay" "
"Test4"~"Test4 Job"~"Complete"~"Job completed without any issues"


SQL> select * from t;

JOBID                JOBNAME                        STATUS                         COMMENTS
-------------------- ------------------------------ ------------------------------ ----------------------------------------------
Test1                Test1 Job                      Complete                       Job completed without any issues
Test2                Test2 Job                      In-progress                    Job has dependency with "test0" job status
Test3                Test3 Job                      In-progress                    Job will start from "Next weekFrdiay"
Test4                Test4 Job                      Complete                       Job completed without any issues



Is this answer out of date? If it is, please let us know via a Comment