简体   繁体   中英

How could i loop this query?

I have following sql query in Oracle.

SELECT pr.uuid AS masterproductid, 
            (case 
                when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint1"]/string/text()') IS NOt NULL THEN 'sellingpoint1'
                when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint2"]/string/text()') IS NOt NULL THEN 'sellingpoint2'
            END
            ) as testt
  FROM product pr WHERE pr.defaultproductvariationid =(SELECT prv.uuid FROM  productvariation prv WHERE  prv.uuid = '3rep_vEBP6IAAAE83REjnPbb' AND pr.typecode='16')

In the case-when both 'sellingpoint1' and 'sellingpoint2' is not null but this query returns only sellingpoint1, i want 'sellingpoint2' also how can i get that?

Thanks for help

This puts it into two columns:

SELECT pr.uuid AS masterproductid, 
            (case when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint1"]/string/text()') IS NOt NULL
                 THEN 'sellingpoint1'
             end) as testsellingpoint1,
            (case when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint2"]/string/text()') IS NOt NULL
                  THEN 'sellingpoint2'
             END
            ) as testsellingpoint2
  FROM product pr WHERE pr.defaultproductvariationid =(SELECT prv.uuid FROM  productvariation prv WHERE  prv.uuid = '3rep_vEBP6IAAAE83REjnPbb' AND pr.typecode='16')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM