我正在尝试使用sqlldr将数据导入Oracle数据库。
描述我在做什么:
创建varray类型和表:
CREATE OR REPLACE TYPE fv_integer_varray_12 AS VARRAY(12) OF INTEGER NOT NULL;
CREATE OR REPLACE TYPE VC_Array_MInteger_12 AS Object (
fv_array fv_integer_varray_12,
MEMBER FUNCTION typeDimension RETURN NUMBER ,
MEMBER FUNCTION typeName RETURN VARCHAR2);
/
CREATE TABLE fv_varray_12 (
id NUMBER,
fv fv_integer_varray_12,
PRIMARY KEY (id)
);
创建控制文件:
options (errors=9999999, rows=5)
load data
characterset WE8MSWIN1252
infile '<path>'
badfile '<path>'
discardfile '<path>'
into table fv_varray_12
fields terminated by " "
( id, fv VARRAY COUNT(12) (fv))
要加载的数据是:
8 18 29 38 9 16 15 14 16 18 16 13 15
9 22 31 32 8 13 18 10 15 18 16 13 13
当我尝试通过命令加载它时:
sqlldr user/pass control=imp_fv_12dim.ctl
我收到错误:
SQL * Loader-403:表FV_VARRAY_12中没有引用的列。
但这不是真的,因为id和fv列都在那里。
我的控制文件一定有问题。我该如何解决?
答案 0 :(得分:1)
您只是错过了关键字CONSTANT
:
fv VARRAY COUNT(CONSTANT 12) (fv)
文档中的示例中缺少(但随后它们的数据看起来也很奇怪);但它显示为必需in the count_spec syntax diagram,在加载VARRAY时链接到the 12c documentaion - 但也可以在早期版本的文档中使用..
使用您的示例数据以及对控制文件的修改:
options (errors=9999999, rows=5)
load data
characterset WE8MSWIN1252
infile 'imp_fv_12dim.dat'
badfile 'imp_fv_12dim.bad'
discardfile 'imp_fv_12dim.dis'
into table fv_varray_12
fields terminated by " "
( id,
fv VARRAY COUNT(CONSTANT 12) (fv)
)
然后它起作用:
> sqlldr user/pass control=imp_fv_12dim.ctl
SQL*Loader: Release 11.2.0.4.0 - Production on Mon Dec 4 17:41:04 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Commit point reached - logical record count 2
查询显示数据:
column fv format a80
select * from fv_varray_12;
ID FV
---------- --------------------------------------------------------------------------------
8 FV_INTEGER_VARRAY_12(18, 29, 38, 9, 16, 15, 14, 16, 18, 16, 13, 15)
9 FV_INTEGER_VARRAY_12(22, 31, 32, 8, 13, 18, 10, 15, 18, 16, 13, 13)