0

i want to import csv file to oracle Database. my csv look like this : enter image description here

Table A : sometimes containing 2 lines or 3 lines or empty. i want to import start Table B. so my control.ctl is :

echo OPTIONS (SKIP=5, errors=12000) 
     LOAD DATA  
     APPEND INTO TABLE xyz 
       when id <> '' and sales = '' 
     FIELDS TERMINATED BY X'09' 
     optionally enclosed by '"' 
     TRAILING NULLCOLS 
     (id "TRIM (:id)", 
      customer "TRIM (:customer)",
      qty "TRIM (:qty)", 
      sales filler)

xyz table is :

create xyz (
id varchar2(3),
customer varchar2(255),
qty varchar2(5)
)

why no data is stored?

Justin Cave
  • 227,342
  • 24
  • 367
  • 384
flyingbird013
  • 446
  • 2
  • 12
  • 28

1 Answers1

0

In Oracle, the empty string is considered null. And null is never equal to nor unequal to any other value including null. You need to use is null or is not null to look for null values.

The predicate

when id <> '' and sales = ''

can never possibly be true. No id value is ever unequal to null and no sales value is ever equal to null. Perhaps you want

when id is not null and sales is null

If you are just trying to avoid loading blank rows, however, I'd expect that your when clause would just be on id not on sales.

Justin Cave
  • 227,342
  • 24
  • 367
  • 384