我有一个使用 Oracle 开发的查询。我想更新同一列
'5次。在我开发的查询下方:
MERGE INTO product pr
USING(
SELECT pr.uuid,
xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint1"]/string/text()') AS sellingpoint1,
xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint2"]/string/text()') AS sellingpoint2,
xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint3"]/string/text()') AS sellingpoint3,
xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint4"]/string/text()') AS sellingpoint4,
xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint5"]/string/text()') AS sellingpoint5
FROM product pr WHERE pr.defaultproductvariationid ='1tap_vEBvuEAAAE89CgjnPbb' AND pr.typecode = '16'
) defaultproducts ON (pr.uuid = '8d2p_vEBCJgAAAE8ruYjnPba')
WHEN MATCHED THEN
UPDATE SET pr.attributes_de_de = CASE WHEN sellingpoint1 IS NOT NULL THEN
CASE WHEN (SELECT count(1) existscount FROM product pr
WHERE pr.uuid = '8d2p_vEBCJgAAAE8ruYjnPba'
AND existsNode(xmltype(pr.attributes_de_de), '/attrs/attr[@name="SellingPoint1"]') = 1) = 1
THEN
UPDATEXML(XMLTYPE.createXML(pr.attributes_de_de),'/attrs/attr[@name = "SellingPoint1"]/string/text()',
sellingpoint1).getClobVal()
ELSE
APPENDCHILDXML(xmltype(pr.attributes_de_de), 'attrs/attr[@name="SellingPoint22"]',
XMLType('<string>test</string>')).getClobVal()
END
ELSE
DELETEXML(xmltype(pr.attributes_de_de), '/attrs/attr[@name="SellingPoint1"]').getClobVal()
END
DELETE where pr.uuid != '8d2p_vEBCJgAAAE8ruYjnPba'
此查询中的挑战是“pr.attribute_de_de”列应更新为 sellpoint1、sellingpoint2、sellingpoint3、sellingpoint4、sellingpoint5。如何在 oracle 中做到这一点。非常感谢您的任何建议