使用 Sql*Loader 进行条件加载
使用 SQL*Loader,我想要这样的条件:
加载记录 if : substr(Col,3,2)='06'
<前><代码>列 ------ 10062034 。 。 。
有没有办法在控制文件中将 WHEN 与 substr (或任何其他函数)结合起来?
我尝试了 WHEN (substr(Col,3,2)='06') 但没有成功。
Using SQL*Loader, I want a condition like this:
Load the record if : substr(Col,3,2)='06'
Col ------ 10062034 . . .
Is there any way to combine WHEN with substr (or any other function) in control file?
I tried WHEN (substr(Col,3,2)='06')
but it didn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,
WHEN
子句的语法非常严格;请参阅http://docs.oracle.com/cd/B14117_01/server.101/b10825/ldr_control_file.htm#i1005657。您只能基于整个字段或特定字符位置进行限制。也就是说,如果您使用固定格式,则可以将 substr(Col,3,2) 表示为字符位置范围,这样就可以了。例如,如果Col
从字符 #20 开始,则可以使用WHEN (22:23) = '06'
。但是,如果您使用自由格式,例如FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
,那么您通常不会知道Col
。No, the syntax for the
WHEN
clause is quite restrictive; see http://docs.oracle.com/cd/B14117_01/server.101/b10825/ldr_control_file.htm#i1005657. You can only restrict based on either an entire field, or else on specific character positions. That said, if you're using a fixed format, then you can expresssubstr(Col,3,2)
as a range of character positions, and that will work. For example, ifCol
starts at character #20, then you can useWHEN (22:23) = '06'
. But if you're using a free format, likeFIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"'
, then you won't generally know the character-offset ofCol
.您可以将 When 与其他函数结合起来,如您的代码:
HTH。
You can combine When with other function, as your code:
HTH.