POSITION后未加载Oracle数据(10)

时间:2017-07-05 11:54:57

标签: oracle csv etl ctl

我一直在尝试根据某些条件从csv文件加载一些数据,并且我受限于使用" OR"在when子句中控制(Oracle ctl) 数据加载前11个条件,但在第11个条件之后不加载任何数据

以下是代码示例

     create table t1 (
     c1 varchar(10),
     c2 varchar(10),
     c3 varchar(10)
     )

---------- -----------的DataLoader

     options(errors=20000)
     LOAD DATA
     INFILE 'D:\Scripts\abc.csv'              
     BADFILE 'D:\Scripts\abc.BAD'
     DISCARDFILE 'D:\Scripts\abc.DIS'
     DISCARDMAX 20000
     insert
     INTO TABLE t1

     when c1='James'

     FIELDS TERMINATED BY "," optionally enclosed by '"'

     Trailing NULLCOLS
     (             
     c1,

     c2,

     c3
     )

     INTO TABLE t1

     when c1='John'

     FIELDS TERMINATED BY "," optionally enclosed by '"'

     Trailing NULLCOLS
     (             
     c1 POSITION(1),

     c2,

     c3
     )

     INTO TABLE t1

     when c1='Sam'

     FIELDS TERMINATED BY "," optionally enclosed by '"'

     Trailing NULLCOLS
     (             
     c1 POSITION(2),

     c2,

     c3
     )
     .
     .
     .         
     INTO TABLE t1

     when c1='Mark'

     FIELDS TERMINATED BY "," optionally enclosed by '"'
     Trailing NULLCOLS
     (             
     c1 POSITION(12),

     c2,

     c3

     )

-------------- dataloader执行-----

     sqlldr scott/tiger direct=true control='filepath'

1 个答案:

答案 0 :(得分:0)

执行我们需要将每个条件的POSITION(1)置于POSITION(9)标记的每个条件。否则ctl文件不会读取标记并忽略条件