我想使用 SQL 开发人员将 XML 文件导入 Oracle SQL。XML 有多个节点,我的 XML 结构:
<SPECTRAEXCHANGE>
<APPLICATION>
<SV_SV_ID>kClong</SV_SV_ID>
<SS_SS_ID>kClong</SS_SS_ID>
<AP_NAME>kCstring (64)</AP_NAME>
<AP_PRJ_IDENT>kCstring (32)</AP_PRJ_IDENT>
<STATION>
<TCS_NAME>kCstring (64)</TCS_NAME>
<TCS_CALL>kCstring (256)</TCS_CALL>
<HORIZONTAL_ELEVATIONS>
<HORIZONTAL_ELEVATION>
<HE_AZIMUT>kCdouble</HE_AZIMUT>
<HE_ELEVATION>kCdouble</HE_ELEVATION>
</HORIZONTAL_ELEVATION>
</HORIZONTAL_ELEVATIONS>
<TRANSMITTER>
<EQP_EQUIP_NAME>kCstring (128)</EQP_EQUIP_NAME>
<EQP_EQUIP_TYPE>kCstring (16)</EQP_EQUIP_TYPE>
<FREQUENCY>
<EFL_FREQ>kCdouble</EFL_FREQ>
<COORDINATED_FREQUENCY>
<COF_DAT>kWrDate</COF_DAT>
</COORDINATED_FREQUENCY>
</FREQUENCY>
</TRANSMITTER>
<RECEIVER>
<EQP_EQUIP_NAME>kCstring (128)</EQP_EQUIP_NAME>
<EQP_EQUIP_TYPE>kCstring (16)</EQP_EQUIP_TYPE>
<FREQUENCY>
<EFL_FREQ>kCdouble</EFL_FREQ>
<COORDINATED_FREQUENCY>
<COF_DAT>kWrDate</COF_DAT>
</COORDINATED_FREQUENCY>
</FREQUENCY>
</RECEIVER>
</STATION>
</APPLICATION>
</SPECTRAEXCHANGE>
首先,我创建了表 SPECTRAEXCHANGE,然后使用了@Alex Poole 的解决方案:
insert into spectra exchange ( ... columns ... )
select a.sv_sv_id, a.ss_ss_id, a.ap_name, a.ap_prj_ident,
s.tcs_name, s.tcs_call,
t.eqp_equip_name, t.eqp_equip_type
from (select xmltype(:raw_xml) xmlcol from dual) r
cross join xmltable('/SPECTRAEXCHANGE/APPLICATION' passing r.xmlcol
columns sv_sv_id varchar2(15) path 'SV_SV_ID',
ss_ss_id varchar2(15) path 'SS_SS_ID',
ap_name varchar2(15) path 'AP_NAME',
ap_prj_ident varchar2(15) path 'AP_PRJ_IDENT',
stations xmltype path 'STATION'
) (+) a
cross join xmltable('/STATION' passing a.stations
columns tcs_name varchar2(15) path 'TCS_NAME',
tcs_call varchar2(15) path 'TCS_CALL',
transmitter xmltype path 'TRANSMITTER'
) (+) s
cross join xmltable('/TRANSMITTER' passing s.transmitter
columns eqp_equip_name varchar2(15) path 'EQP_EQUIP_NAME',
eqp_equip_type varchar2(15) path 'EQP_EQUIP_TYPE',
frequency xmltype path 'FREQUENCY'
) (+) t
/
并且该站具有发射器和接收器路径,我怎样才能在一张表中导入接收器路径?
我创建了一张表,我想将所有内容存储在一张表中。一个应用程序可以包含多个站点,一个站点可以包含更多发射器,一个发射器可以具有更多频率。我创建了一张表,我想将所有内容存储在一张表中