1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
create table dropme_BICDirectory(id integer primary key
, EDNo varchar2(10)
, EDDate varchar2(50)
, EDAuthor varchar2(50)
, CreationReason varchar2(50)
, CreationDateTime varchar2(50)
, InfoTypeCode varchar2(50)
, BusinessDay varchar2(50)
, BIC varchar2(50)
, ParticipantNameP varchar2(50)
, ParticipantCntrCd varchar2(50)
, ParticipantRgn varchar2(50)
, ParticipantInd varchar2(50)
, ParticipantTnp varchar2(50)
, ParticipantNnp varchar2(50)
, ParticipantAdr varchar2(50)
, ParticipantDateIn varchar2(50)
, ParticipantPtType varchar2(50)
, ParticipantSrvcs varchar2(50)
, ParticipantXchType varchar2(50)
, ParticipantUID varchar2(50)
, ParticipantStatus varchar2(50)
) nologging
;
Table created
create table dropme_Accounts(
Account varchar2(50)
, RegulationAccountType varchar2(50)
, CK varchar2(50)
, AccountCBRBIC varchar2(50)
, DateIn varchar2(50)
, AccountStatus varchar2(50)
, fk_BICDirectory integer references dropme_BICDirectory(id)
) nologging
;
Table created
INSERT ALL
WHEN n = 1 THEN
INTO dropme_BICDirectory( id, EDNo, EDDate, EDAuthor, CreationReason, CreationDateTime, InfoTypeCode, BusinessDay, BIC
, ParticipantNameP, ParticipantCntrCd, ParticipantRgn, ParticipantInd, ParticipantTnp, ParticipantNnp
, ParticipantAdr, ParticipantDateIn, ParticipantPtType, ParticipantSrvcs, ParticipantXchType
, ParticipantUID, ParticipantStatus
) VALUES ( SeqNo, EDNo, EDDate, EDAuthor, CreationReason, CreationDateTime, InfoTypeCode, BusinessDay, BIC
, ParticipantNameP, ParticipantCntrCd, ParticipantRgn, ParticipantInd, ParticipantTnp, ParticipantNnp
, ParticipantAdr, ParticipantDateIn, ParticipantPtType, ParticipantSrvcs, ParticipantXchType
, ParticipantUID, ParticipantStatus)
ELSE
INTO dropme_Accounts( Account, RegulationAccountType, CK, AccountCBRBIC, DateIn, AccountStatus, fk_BICDirectory
) VALUES ( Account, RegulationAccountType, CK, AccountCBRBIC, DateIn, AccountStatus, SeqNo
)
with t as (select q'{<?xml version="1.0" encoding="Windows-1251"?>
<ED807 xmlns="urn:cbr-ru:ed:v2.0" EDNo="709594854" EDDate="2020-08-31" EDAuthor="4583001999" CreationReason="FCBD" CreationDateTime="2020-08-31T18:02:12Z" InfoTypeCode="FIRR" BusinessDay="2020-09-01" DirectoryVersion="1">
<BICDirectoryEntry BIC="041280103">
<ParticipantInfo NameP="УФК по Астраханской области" CntrCd="RU" Rgn="12" Ind="414056" Tnp="г" Nnp="Астрахань" Adr="ул Латышева, 6 Г" DateIn="2010-06-08" PtType="52" Srvcs="3" XchType="1" UID="1280002005" ParticipantStatus="PSAC"/>
<Accounts Account="40116810100000010010" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810400000010011" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810700000010012" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810000000010013" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810300000010014" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810600000010015" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
</BICDirectoryEntry>
<BICDirectoryEntry BIC="041280103">
<ParticipantInfo NameP="УФК по Астраханской области" CntrCd="RU" Rgn="12" Ind="414056" Tnp="г" Nnp="Астрахань" Adr="ул Латышева, 6 Г" DateIn="2010-06-08" PtType="52" Srvcs="3" XchType="1" UID="1280002005" ParticipantStatus="PSAC"/>
<Accounts Account="40116810100000010010" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810400000010011" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810700000010012" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810000000010013" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810300000010014" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
<Accounts Account="40116810600000010015" RegulationAccountType="TRSA" CK="99" AccountCBRBIC="041280002" DateIn="2013-01-09" AccountStatus="ACAC"/>
</BICDirectoryEntry>
</ED807>}' x from dual)
select *
from t
, xmltable( XMLNAMESPACES(DEFAULT 'urn:cbr-ru:ed:v2.0')
, '/ED807/BICDirectoryEntry'
passing xmltype(x)
columns SeqNo for ordinality
, EDNo varchar2(10) path './../@EDNo'
, EDDate varchar2(50) path './../@EDDate' --="2020-08-31"
, EDAuthor varchar2(50) path './../@EDAuthor' --="4583001999"
, CreationReason varchar2(50) path './../@CreationReason' --="FCBD"
, CreationDateTime varchar2(50) path './../@CreationDateTime' --="2020-08-31T18:02:12Z"
, InfoTypeCode varchar2(50) path './../@InfoTypeCode' --="FIRR"
, BusinessDay varchar2(50) path './../@BusinessDay' --="2020-09-01"
, BIC varchar2(50) path '@BIC' --="2020-09-01"
, ParticipantNameP varchar2(50) path './ParticipantInfo[1]/@NameP'
, ParticipantCntrCd varchar2(50) path './ParticipantInfo[1]/@CntrCd'
, ParticipantRgn varchar2(50) path './ParticipantInfo[1]/@Rgn'
, ParticipantInd varchar2(50) path './ParticipantInfo[1]/@Ind'
, ParticipantTnp varchar2(50) path './ParticipantInfo[1]/@Tnp'
, ParticipantNnp varchar2(50) path './ParticipantInfo[1]/@Nnp'
, ParticipantAdr varchar2(50) path './ParticipantInfo[1]/@Adr'
, ParticipantDateIn varchar2(50) path './ParticipantInfo[1]/@DateIn'
, ParticipantPtType varchar2(50) path './ParticipantInfo[1]/@PtType'
, ParticipantSrvcs varchar2(50) path './ParticipantInfo[1]/@Srvcs'
, ParticipantXchType varchar2(50) path './ParticipantInfo[1]/@XchType'
, ParticipantUID varchar2(50) path './ParticipantInfo[1]/@UID'
, ParticipantStatus varchar2(50) path './ParticipantInfo[1]/@ParticipantStatus'
, Accounts xmltype path 'Accounts'
) BICDirectoryEntry
, xmltable( XMLNAMESPACES(DEFAULT 'urn:cbr-ru:ed:v2.0')
, '/Accounts' passing BICDirectoryEntry.Accounts
columns n for ordinality
, Account varchar2(50) path '@Account'
, RegulationAccountType varchar2(50) path '@RegulationAccountType'
, CK varchar2(50) path '@CK'
, AccountCBRBIC varchar2(50) path '@AccountCBRBIC'
, DateIn varchar2(50) path '@DateIn'
, AccountStatus varchar2(50) path '@AccountStatus'
)(+) Accounts
;
12 rows inserted
SQL>