使用联接到其他表来更新Oracle中的XML元素

时间:2019-03-31 08:08:59

标签: sql xml oracle

我在XMLTYPE列中存储了一个XML,其中包含加密的元素,我需要通过连接到其他表将其替换为解密的值。

-- Sample XML
<Root_Element xmlns="http://euroconsumers.org/notifications/2019/01/notification">    
    <DocID>ABCD1234</DocID>
    <InsertDate>2019-03-01</InsertDate>
    <TimeSeries>
        <Received_DocID>123456</Received_DocID>
        <Encrypted_ProviderID>PROV001</Encrypted_ProviderID>
        <Point>
            <Encrypted_BidID>BD001</Encrypted_BidID>
            <Amount>1.63</Amount>
        </Point>
    </TimeSeries>
    <TimeSeries>
        <Received_DocID>123456</Received_DocID>
        <Encrypted_ProviderID>PROV001</Encrypted_ProviderID>
        <Point>
            <Encrypted_BidID>BD002</Encrypted_BidID>
            <Amount>1.63</Amount>
        </Point>
    </TimeSeries>
    <TimeSeries>
        <Received_DocID>987654</Received_DocID>
        <Encrypted_ProviderID>PROV002</Encrypted_ProviderID>
        <Point>
            <Encrypted_BidID>BD101</Encrypted_BidID>
            <Amount>1.85</Amount>
        </Point>
    </TimeSeries>
</Root_Element>

-- PROVIDERS table

ProviderID Encrypted_ProviderID
PROVEU     PROV001
PROVUK     PROV002

-- BIDS table

Received_DocID BidID Encrypted_BidID
123456         1111  BD001
123456         2222  BD002
987654         3333  BD101


-- Expected output
<Root_Element xmlns="http://euroconsumers.org/notifications/2019/01/notification">    
    <DocID>ABCD1234</DocID>
    <InsertDate>2019-03-01</InsertDate>
    <TimeSeries>
        <Received_DocID>123456</Received_DocID>
        <Encrypted_ProviderID>PROVEU</Encrypted_ProviderID>
        <Point>
            <Encrypted_BidID>111</Encrypted_BidID>
            <Amount>1.63</Amount>
        </Point>
    </TimeSeries>
    <TimeSeries>
        <Received_DocID>123456</Received_DocID>
        <Encrypted_ProviderID>PROVEU</Encrypted_ProviderID>
        <Point>
            <Encrypted_BidID>2222</Encrypted_BidID>
            <Amount>1.63</Amount>
        </Point>
    </TimeSeries>
    <TimeSeries>
        <Received_DocID>987654</Received_DocID>
        <Encrypted_ProviderID>PROVUK</Encrypted_ProviderID>
        <Point>
            <Encrypted_BidID>3333</Encrypted_BidID>
            <Amount>1.85</Amount>
        </Point>
    </TimeSeries>
</Root_Element>

该标记将在XML中重复大约1000次,因此更新必须快速且尽可能在一条语句中进行。

使用XMLQuery可以轻松便捷地做到这一点吗?

数据库为Oracle 11.2.0.3

0 个答案:

没有答案