0

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

我的表如下所示:

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

这是我的 CTL 和 DAT 文件:

加载器.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)

加载器.dat

3;my_file.txt

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

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

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

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

    ^

我做错了什么还是 SQL Loader 不接受 BFILE?

谢谢,

4

1 回答 1

1

该文档有一个关于加载 BFILE 列的部分

您需要有一个填充列来表示数据文件中的文件名字段,然后在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字段被声明为integer; 这是一个全字二进制整数,您可能不会在表列中获得您期望的值。

如果要显式转换为数字,可以执行以下操作:

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

但隐式转换通常也可以。

于 2017-03-08T16:03:51.933 回答