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」列を、sellingpoint1、sellingpoint2、sellingpoint3、sellingpoint4、sellingpoint5 に対して更新する必要があることです。オラクルでこれを行う方法。ご提案いただきありがとうございます