我有接近同样的事情,但它与“吃桃子”的答案不太相符。我在 xmltype 列中有类似以下内容。
<?xml version="1.0" encoding="UTF-8"?>
<serviceRequestAnswer xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ns2="http://www.something.something/bla/v1">
<Persons>
<Person>
<InternalIdNumber>2935612467</InternalIdNumber>
<PublicIdNumber>9871256327</PublicIdNumber>
<FirstNames>Remy</FirstNames>
<LastName>Smith</LastName>
<BirthName>Smith</BirthName>
<BirthDate>19900101</BirthDate>
<PlaceOfBirth>0209</PlaceOfBirth>
<CountryOfBirth>6030</CountryOfBirth>
<Sex>M</Sex>
<Nationality>0001</Nationality>
</Person>
<Person>
<InternalIdNumber>7163584061</InternalIdNumber>
<PublicIdNumber>123432678</PublicIdNumber>
<FirstNames>Jesse</FirstNames>
<LastName>Smith</LastName>
<BirthName>Smith</BirthName>
<BirthDate>19900101</BirthDate>
<PlaceOfBirth>0012</PlaceOfBirth>
<CountryOfBirth>6030</CountryOfBirth>
<Sex>M</Sex>
<Nationality>0001</Nationality>
</Person>
</Persons>
</serviceRequestAnswer>
让我们将列称为 xmlcontent,并将其放在名为 mytable 的表中。然后将 2 个公共 ID 号提取为 2 行,如下所示:
select
nvl(value (line).extract ('/Person/PublicIdNumber/text()').getstringval (),'') PublicId
from mytable, table ( xmlsequence (extract(xmlcontent,'serviceRequestAnswer/Persons/Person'))) line
where id_mytable = 10092053;
希望这可以帮助某人:)