我试图在Oracle 11g中加载大型XML文件并将其解析到新表中(对此部分我有SQL查询),但是我无法在SQL * Loader控制文件中设置正确的设置。我对Oracle有点陌生,在在线搜索解决方案和Oracle说明后,无法解决我的问题,我正在寻求您的帮助。我正在使用Windows 10和SQL Developer 4.0.3.16运行查询以在Oracle中创建表。
上一个帖子中回答了这个问题,但是建议的解决方案对我不起作用(When trying to load a clob to an Oracle table, loading too many records),但是我无法使其工作。
我已经使用了上一个网页中的两个控制文件,而只有第一个控制文件对我来说有相同的问题(在多行中插入了相同的XML) 我正在提示中运行此代码:
sqlldr rc_tables/xxuser@xx.xxx.xx.xx/euxxxx control='control_file.ctl' log = 'data_log.log'
控制文件:
LOAD DATA
CHARACTERSET UTF8
INFILE 'C:\Users\...\NVTPOI_03_MEX_9701_001.xml'
REPLACE
INTO TABLE LEAD_REPORTING_CLOB
TRAILING NULLCOLS
(
XML LOBFILE(CONSTANT 'C:\...\NVTPOI_03_MEX_9701_001.xml') TERMINATED BY EOF
)
我创建的表是:
CREATE TABLE "LEAD_REPORTING_CLOB"
(SHARED_XML CLOB);
如果我使用第二种方法(上一篇文章中的解决方案),如果我决定运行它而不将FILENAME字段添加到表中,则会收到一条错误消息:
SQL * Loader-416:表LEAD_REPORTING_CLOB中的字段SHARED_XML的SDF子句引用了一个不存在的字段。
控制文件:
LOAD DATA
INFILE *
REPLACE
INTO TABLE LEAD_REPORTING_CLOB
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
SHARED_XML LOBFILE(FILENAME) TERMINATED BY EOF
)
BEGINDATA
'C:\Users\ivcrespo\Documents\projects\2018\oracle\NVTPOI_CHL_9500_001.xml'
我还尝试了使用带有FILENAME char(100)字段的表的上一个控制文件,但是id并没有加载任何内容。
控制文件:
LOAD DATA
INFILE *
REPLACE
INTO TABLE LEAD_REPORTING_CLOB
FIELDS TERMINATED BY ',' TRAILING NULLCOLS
(
FILENAME,
SHARED_XML LOBFILE(FILENAME) TERMINATED BY EOF
)
BEGINDATA
'C:\Users\ivcrespo\Documents\projects\2018\oracle\NVTPOI_CHL_9500_001.xml'
SQL*Loader: Release 11.2.0.1.0 - Production on Wed Jul 4 08:39:35 2018
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Control File: control_file_xml_test2.ctl
Data File: control_file_xml_test2.ctl
Bad File: control_file_xml_test2.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table LEAD_REPORTING_CLOB, loaded from every logical record.
Insert option in effect for this table: REPLACE
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
------------------------------ ---------- ----- ---- ---- ---------------------
FILENAME FIRST * , CHARACTER
SHARED_XML DERIVED * EOF CHARACTER
Dynamic LOBFILE. Filename in field FILENAME
Table LEAD_REPORTING_CLOB:
0 Rows successfully loaded.
0 Rows not loaded due to data errors.
0 Rows not loaded because all WHEN clauses were failed.
0 Rows not loaded because all fields were null.
Space allocated for bind array: 16512 bytes(64 rows)
Read buffer bytes: 1048576
Total logical records skipped: 0
Total logical records read: 0
Total logical records rejected: 0
Total logical records discarded: 0
Run began on Wed Jul 04 08:39:35 2018
Run ended on Wed Jul 04 08:39:37 2018
Elapsed time was: 00:00:02.16
CPU time was: 00:00:00.03
有人可以帮助我设置此权限吗?我在网上找到的示例通常显示控制文件,而不显示创建的表。我创建的表中有错误吗? 这将是XML文件第一个节点的示例(每个文件中可以包含数百个):
<?xml version="1.0" encoding="UTF-8"?>
<DeliveryPackage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:saxon="http://saxon.sf.net/"
CreationTime="2018-06-18T13:07:40.196Z"
VersionNo="Q318">
<POI>
<Action>Add</Action>
<SupplierID>3</SupplierID>
<Identity>
<POI_Entity_ID>109034</POI_Entity_ID>
<Names>
<POI_Name Type="Official" Language_Code="SPA">
<Text>RAFAEL MURILLO VIDAL</Text>
</POI_Name>
</Names>
<Category_ID Type="NT">9701</Category_ID>
<Product_Type>7</Product_Type>
</Identity>
<Locations>
<Location>
<Address>
<ParsedAddress>
<ParsedStreetAddress>
<ParsedStreetName>
<StreetName Language_Code="SPA">RAFAEL MURILLO VIDAL</StreetName>
<StreetType Language_Code="SPA" Before="true" Attached="false">AVENIDA</StreetType>
</ParsedStreetName>
</ParsedStreetAddress>
<ParsedPlace>
<PlaceLevel2 Language_Code="SPA">VERACRUZ DE IGNACIO DE LA LLAVE</PlaceLevel2>
<PlaceLevel3 Language_Code="SPA">XALAPA</PlaceLevel3>
<PlaceLevel4 Language_Code="SPA">CUAUHTÉMOC</PlaceLevel4>
</ParsedPlace>
<Zone Language_Code="SPA" Type="KD">XALAPA DE ENRÍQUEZ</Zone>
<PostalCode>
<NT_Postal>91069</NT_Postal>
</PostalCode>
<CountryCode>MEX</CountryCode>
</ParsedAddress>
</Address>
<GeoPosition>
<Latitude>19.51919</Latitude>
<Longitude>-96.90392</Longitude>
</GeoPosition>
<MapLinkID>
<LinkID>919722915</LinkID>
<Side_of_Street>R</Side_of_Street>
<Percent_from_RefNode>30</Percent_from_RefNode>
</MapLinkID>
<Confidence>
<Match_Level>GeoPoint</Match_Level>
</Confidence>
</Location>
</Locations>
<Details>
<Camera>
<CameraType>Speed</CameraType>
<SpeedLimit Unit="KPH">60</SpeedLimit>
<DrivingDirection LinkHeading="T">110</DrivingDirection>
</Camera>
</Details>
</POI>
.
.
</DeliveryPackage>