SQL*Loader - How can i ignore certain rows with a

2019-08-13 03:29发布

If i have a CSV file that is in the following format

"fd!","sdf","dsfds","dsfd"
"fd!","asdf","dsfds","dsfd"
"fd","sdf","rdsfds","dsfd"
"fdd!","sdf","dsfds","fdsfd"
"fd!","sdf","dsfds","dsfd"
"fd","sdf","tdsfds","dsfd"
"fd!","sdf","dsfds","dsfd"

Is it possible to exclude any row where the first column has an exclamation mark at the end of the string. i.e. it should only load the following rows

"fd","sdf","rdsfds","dsfd"
"fd","sdf","tdsfds","dsfd"

Thanks

2条回答
姐就是有狂的资本
2楼-- · 2019-08-13 03:51

According to the Loading Records Based on a Condition section of the SQL*Loader Control File Reference (11g):

"You can choose to load or discard a logical record by using the WHEN clause to test a condition in the record."

So you'd need something like this:

LOAD DATA ... INSERT INTO TABLE mytable   WHEN mycol1 NOT LIKE '%!' 
(mycol1..  ,mycol2 ..)

But the LIKE operator is not available! You only have = and !=

Maybe you could try an External Table instead.

查看更多
Evening l夕情丶
3楼-- · 2019-08-13 04:15

I'd stick a CONSTRAINT on the table, and just let them be rejected. Maybe delete them after load. Or a unix "grep -v" to clear them out the file.

查看更多
登录 后发表回答