sql—如何在clob列中插入数据(oracle)

368yc8dk  于 2021-08-13  发布在  Java
关注(0)|答案(1)|浏览(440)

我有table:tbl\U样品

SAMPLE_ID - Primary Key
SAMPLE_CD - String
statusDateTime - DateTime
DATA_AREA - CLOB

我有这个模式:

<schema>
<parameterizationId label="Samp Id" mapField="SAMPLE_ID" dataType="string"/>
<statusDateTime required="true" dataType="dateTime" default="%CurrentDateTime" mapField="STATUS_UPD_DTTM"/>
<user default="%CurrentUser" mapField="USER_ID" dataType="string"/>
<dataArea type="group" mapXML="DATA_AREA">
    <accountId dataType="string"/>
    <saId dataType="string"/>
    <saTypeCode dataType="string"/>
    <endDate dataType="date"/>
    <beginBalAmt dataType="number"/>
</dataArea>

我需要填充date\u area clob列,应该如下所示:(预期)

<accountId>0854215</accountId><saId>745152</saId><saTypeCode>TES</saTypeCode><endDate>16-Dec-2019</endDate><beginBalAmt>10525</beginBalAmt>

我有一个现有的sql:

INSERT INTO TBL_DIFF
SELECT
SA.ACCT_ID,SA.SA_ID,SA.SA_TYPE_CD,'31-DEC-16',0
FROM CI_SA SA

我想用上面提供的预期输出,使用这个sql语句填充data\u area列。怎么做?

q35jwt9p

q35jwt9p1#

您只需按如下方式使用concatation:

INSERT INTO TBL_DIFF
    SELECT
        '<accountId>' || SA.ACCT_ID || '</accountId><saId>' || SA.SA_ID || '</saId><saTypeCode>' || SA.SA_TYPE_CD || '</saTypeCode><endDate>'
        || END_DATE || '</endDate><beginBalAmt>' || BEGINBALAMT || '</beginBalAmt>'
    FROM
        (
            SELECT
                SA.ACCT_ID,
                SA.SA_ID,
                SA.SA_TYPE_CD,
                '31-DEC-16' END_DATE,
                0 BEGINBALAMT
            FROM
                CI_SA SA
            WHERE
                SA.SA_TYPE_CD = 'LOAN'
        );

相关问题