我使用Oracle 11g XMLTABLE函数来从附加的XML文件中的数据。 当我执行的代码,我得到3行。 我检索产品正确生成对应于每一个客户的产品一行。 问题是,我没有收到客户数据的其余部分,我得到了客户名称,CustomerDOB和CustomerEmail空。 出于某种原因的代码,我使用,甲骨文没有取2级的水平了。 请帮忙! 我究竟做错了什么?
XML
<?xml version="1.0" encoding="iso-8859-1"?>
<USACustomers>
<NewYorkCustomers>
<Customer>
<CustomerData>
<CustomerName>John Stark</CustomerName>
<CustomerDOB>07/09/1973</CustomerDOB>
<CustomerEmail>j.stark@liquid.com</CustomerEmail>
</CustomerData>
<CustomerAddress>
<Address>400 Railroad Way</Address>
<City>Larchmont</City>
<State>NY</State>
<Zip>10542</Zip>
</CustomerAddress>
<CustomerProducts>
<CustomerProduct>
<PoductType>CTD</PoductType>
<ProductNumber>2050035302</ProductNumber>
</CustomerProduct>
<CustomerProduct>
<PoductType>REC</PoductType>
<ProductNumber>2050920400</ProductNumber>
</CustomerProduct>
</CustomerProducts>
</Customer>
<Customer>
<CustomerData>
<CustomerName>Maria Stark</CustomerName>
<CustomerDOB>07/09/1972</CustomerDOB>
<CustomerEmail>m.stark@liquid.com</CustomerEmail>
</CustomerData>
<CustomerAddress>
<Address>410 Railroad Way</Address>
<City>Larchmont</City>
<State>NY</State>
<Zip>10542</Zip>
</CustomerAddress>
<CustomerProducts>
<CustomerProduct>
<PoductType>REC</PoductType>
<ProductNumber>2050920400</ProductNumber>
</CustomerProduct>
</CustomerProducts>
</Customer>
</NewYorkCustomers>
</USACustomers>
码
SELECT
CustomerName,
CustomerDOB,
CustomerEmail,
PoductType
FROM XMLTABLE ( '/USACustomers/NewYorkCustomers/Customer/CustomerProducts/CustomerProduct'
PASSING xmltype (BFILENAME ('BACKUP', 'TEST.xml'), NLS_CHARSET_ID ('AL32UTF8'))
COLUMNS CustomerName VARCHAR2(50) PATH 'CustomerData/CustomerName',
CustomerDOB VARCHAR2(50) PATH 'CustomerData/CustomerDOB',
CustomerEmail VARCHAR2(50) PATH 'CustomerData/CustomerEmail',
PoductType VARCHAR2(50) PATH 'PoductType',
ProductNumber VARCHAR2(50) PATH 'ProductNumber');