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

ε祈祈猫儿з 提交于 2019-12-11 05:37:47

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2419182/sqlloader-how-can-i-ignore-certain-rows-with-a-specific-charactre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!