【问题标题】:loading bfile via SQL Loader通过 SQL Loader 加载文件
【发布时间】:2017-03-09 00:11:38
【问题描述】:

我正在尝试使用 SQL 加载器将值加载到其中一列是 BFILE 的表中。

我的桌子是这样的:

create table documents 
    ( id number primary key
    , text bfile)

这是我的 CTL 和 DAT 文件:

loader.ctl

load data
infile d':\test\loader.dat'
into table documents
replace
fields terminated by ';'
    ( id integer
    , text bfilename('MY_DIRECTORY', 'my_file.txt') terminated by eof)

loader.dat

3;my_file.txt

当我使用上面的参数执行 sqlldr 命令时,我收到了错误消息:

SQL*Loader-350:第 7 行的 Suntax 错误。

期待“,”或“)”,找到“bfilename”。

    , text bfilename('MY_DIRECTORY', 'my_file.txt') terminated by eof)

    ^

是我做错了什么还是 SQL 加载器不接受 BFILE?

谢谢,

【问题讨论】:

  • 对不起,我发错信息时出错了

标签: oracle sql-loader bfile


【解决方案1】:

文档有a section on loading BFILE columns

您需要有一个填充列来表示数据文件中的文件名字段,然后在bfile() - 而不是bfilename() - 字段定义中引用该填充字段名称:

load data
infile d:\test\loader.dat
into table documents
replace
fields terminated by ';'
    ( id
    , filename filler
    , text bfile(constant 'MY_DIRECTORY', filename) )

您不希望您的 ID 字段被声明为 integerthis is a full-word binary integer,你可能不会在你的表格列中得到你期望的值。

如果您想显式转换为数字,您可以这样做:

...
fields terminated by ';'
    ( id "to_number(:id)"
    , filename filler
    , text bfile(constant 'MY_DIRECTORY', filename) )

但隐式转换通常也可以。

【讨论】:

  • 解决方案是将行加载到表中,但是......它们似乎没有链接到硬盘的物理位置。当我浏览表格并尝试保存其中一个文件时,它给了我一个错误。 “在 oracle.dbtools.raptor.controls.celleditor.ExtendedTypeEditPanel.saveToDisk(ExtendedTypeEditPanel.java:398) 在 oracle.dbtools 的 oracle.dbtools.raptor.extendedtype.BFILEType.saveToDisk(BFILEType.java:106) 的 java.lang.NullPointerException .raptor.controls.celleditor.BFileEditPanel.processExtendedType(BFileEditPanel.java:192)"
  • " 在 oracle.dbtools.raptor.controls.celleditor.ResultSetCellEditor.showExtendedTypeEdit(ResultSetCellEditor.java:299) 在 oracle.dbtools.raptor.controls.celleditor.ResultSetCellEditor.access$200(ResultSetCellEditor.java: 52) 在 oracle.dbtools.raptor.controls.celleditor.ResultSetCellEditor$1.actionPerformed(ResultSetCellEditor.java:140) 在 javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849) 在 javax.swing.AbstractButton$Handler.actionPerformed( AbstractButton.java:2169)"
  • " 在 javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420) 在 javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) 在 javax.swing.plaf.basic.BasicButtonListener。 mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:5517) at javax.swing.JComponent.processMouseEvent(JComponent.java:3135) at java.awt.Component.processEvent(Component.java :5282) 在 java.awt.Container.processEvent(Container.java:1966) 在 java.awt.Component.dispatchEventImpl(Component.java:3984)"
  • " 在 java.awt.Container.dispatchEventImpl(Container.java:2024) 在 java.awt.Component.dispatchEvent(Component.java:3819) 在 java.awt.LightweightDispatcher.retargetMouseEvent(Container. java:4212) 在 java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892) 在 java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822) 在 java.awt.Container.dispatchEventImpl(Container.java:2010) 在java.awt.Window.dispatchEventImpl(Window.java:1791) 在 java.awt.Component.dispatchEvent(Component.java:3819) 在 java.awt.EventQueue.dispatchEvent(EventQueue.java:463)"
  • " 在 java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242) 在 java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread. java:157) 在 java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) 在 java.awt.EventDispatchThread.run(EventDispatchThread.java:110)"
猜你喜欢
  • 2011-12-30
  • 1970-01-01
  • 1970-01-01
  • 2015-03-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多