0

I am having text file contaning field in below manner.

"64252368","7489040","305762",
"64285217","12132108","787341",

I am using a below control file.

OPTIONS (SKIP=1)
LOAD DATA
TRUNCATE INTO TABLE test_table
FIELDS TERMINATED BY '",'

(
        LEARNEVENT_ID,
        ORGANIZATION,
        COURSE_ID
)

But, I am getting the error:

Record 1: Rejected - Error on table test_table, column LEARNEVENT_ID
ORA-01722: invalid number

Kindly help me on it.

2 Answers 2

2

You need to change your ctl file to include OPTIONALLY ENCLOSED BY option.

OPTIONS (SKIP=1)
LOAD DATA
TRUNCATE INTO TABLE test_table
FIELDS TERMINATED BY ','
 OPTIONALLY ENCLOSED BY '"'
(
        LEARNEVENT_ID,
        ORGANIZATION,
        COURSE_ID
)

I'd recommend reading up on SQL*Loader.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks Ben, when i am trying to use enclosed by in my control file now geeting below error. no terminator found after TERMINATED and ENCLOSED field
If you data ends in a comma, then using TRAILING NULLCOLS. Remove this line if it doesn't...
my data end with comma. kindly suggest me what should i have to do in this case?
Apparently TRAILING NULLCOLS isn't needed in this situation. It worked for me without.., which I find a little confusing but never mind.
@Praveenk.Agrawal : If you are content with this answer you should accept it, which is how all the sites on StackExchange (including this one) work.
0

The problem lays with the encapsulation of the numbers with the quotes " " and your fields terminated by '",' simply does not strip the quotes.

Try this

OPTIONS(SKIP=1)
LOAD DATA
TRUNCATE INTO TABLE test_table
FIELDS TERMINATED BY ','
TRAILING NULLCOLS
(
  LEARNEVENT_ID "replace ( :LEARNEVENT_ID ,'"', '')",
  ORGINAZATION "replace ( :ORGINAZATION ,'"', '')",
  COURSE_ID "replace ( :COURSE_ID ,'"', '')"
)

2 Comments

okay those are only numbers, but instead you should used Ben's solution.
The question only applies to numbers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.