从oracle查询创建的XML
我在下面写了查询以生成xml文件从oracle查询创建的XML,xml,oracle,xelement,Xml,Oracle,Xelement,我在下面写了查询以生成xml文件 SELECT XMLElement("Providers", XMLElement("Provider" ,XMLAttributes( "Unique ID" as "UniqueId"), XMLElement("ProviderType", "Provider Type"),
SELECT XMLElement("Providers",
XMLElement("Provider" ,XMLAttributes(
"Unique ID" as "UniqueId"),
XMLElement("ProviderType", "Provider Type"),
XMLElement("Specialities",
XMLElement("Speciality", "Specialty")),
XMLElement("Relationships",
XMLElement("Relationship", "Relationship")),
XMLElement("ServiceAddress",
XMLElement("AddressLine1","P Address Line 1"),
XMLElement("AddressLine2","P Address Line 2"),
XMLElement("AddressLine3","P Address Line 3"),
XMLElement("AddressLine4","P Address Line 4"),
XMLElement("City","Service city description"),
XMLElement("Region","PState_Province_Region"),
XMLElement("PostalCode","PPostal Code"),
XMLElement("IsoCountryCode","ServiceCountry ISO code")),
XMLElement("Contacts",
XMLElement("ContactInfo",
XMLElement("ContactType","Contact Type"),
XMLElement("Name","Contact Name"),
XMLElement("Title","Contact Title"),
XMLElement("Function","Contact Function"),
XMLElement("PhoneNo","Contact Phone Number"),
XMLElement("CellNo","Contact Cell Phone Number"),
XMLElement("Email","Contact E-mail") ))))
AS "RESULT"
FROM providers_xml
但这将为表提供程序中的每一行创建单独的xml文件,如下所示
文件1
<?xml version="1.0"?>
-<Providers>
-<Provider UniqueId="AA">
<ProviderType>1</ProviderType>
-<Specialities>
<Speciality>210</Speciality>
</Specialities>
-<Relationships>
<Relationship/></Relationships>
-<ServiceAddress>
<AddressLine1>ABC</AddressLine1>
<AddressLine2/><AddressLine3/>
<AddressLine4/>
<City>city123</City>
<Region/>
<PostalCode/>
<IsoCountryCode>US</IsoCountryCode>
</ServiceAddress>
-<Contacts>
-<ContactInfo>
<ContactType>1</ContactType>
<Name>General Contact</Name>
<Title/>
<Function/>
<PhoneNo/>
<CellNo/>
<Email/>
</ContactInfo>
</Contacts>
</Provider>
</Providers>
-
-
1.
-
210
-
-
基础知识
城市123
美国
-
-
1.
一般接触
文件2
<?xml version="1.0"?>
-<Providers>
-<Provider UniqueId="ABC">
<ProviderType>1</ProviderType>
-<Specialities>
<Speciality>100</Speciality>
</Specialities>
-<Relationships>
<Relationship/></Relationships>
-<ServiceAddress>
<AddressLine1>zxy</AddressLine1>
<AddressLine2/><AddressLine3/>
<AddressLine4/>
<City>city300</City>
<Region/>
<PostalCode/>
<IsoCountryCode>US</IsoCountryCode>
</ServiceAddress>
-<Contacts>
-<ContactInfo>
<ContactType>2</ContactType>
<Name>General Contact</Name>
<Title/>
<Function/>
<PhoneNo/>
<CellNo/>
<Email/>
</ContactInfo>
</Contacts>
</Provider>
</Providers>
-
-
1.
-
100
-
-
zxy
城市300
美国
-
-
2.
一般接触
但我需要所有这些文件如下
-<Providers>
-<Provider UniqueId="AA">
<ProviderType>1</ProviderType>
-<Specialities>
<Speciality>210</Speciality>
</Specialities>
-<Relationships>
<Relationship/></Relationships>
-<ServiceAddress>
<AddressLine1>ABC</AddressLine1>
<AddressLine2/><AddressLine3/>
<AddressLine4/>
<City>city123</City>
<Region/>
<PostalCode/>
<IsoCountryCode>US</IsoCountryCode>
</ServiceAddress>
-<Contacts>
-<ContactInfo>
<ContactType>1</ContactType>
<Name>General Contact</Name>
<Title/>
<Function/>
<PhoneNo/>
<CellNo/>
<Email/>
</ContactInfo>
</Contacts>
</Provider>
-<Provider UniqueId="ABC">
<ProviderType>1</ProviderType>
-<Specialities>
<Speciality>100</Speciality>
</Specialities>
-<Relationships>
<Relationship/></Relationships>
-<ServiceAddress>
<AddressLine1>zxy</AddressLine1>
<AddressLine2/><AddressLine3/>
<AddressLine4/>
<City>city300</City>
<Region/>
<PostalCode/>
<IsoCountryCode>US</IsoCountryCode>
</ServiceAddress>
-<Contacts>
-<ContactInfo>
<ContactType>2</ContactType>
<Name>General Contact</Name>
<Title/>
<Function/>
<PhoneNo/>
<CellNo/>
<Email/>
</ContactInfo>
</Contacts>
</Provider>
</Providers>
-
-
1.
-
210
-
-
基础知识
城市123
美国
-
-
1.
一般接触
-
1.
-
100
-
-
zxy
城市300
美国
-
-
2.
一般接触
请帮助获取所需的o/p并添加XMLAGG子句
SELECT XMLElement("Providers",
**XMLAGG(**
XMLElement("Provider" ,XMLAttributes(
"Unique ID" as "UniqueId
听起来你在寻找选择xmlement(“提供者”,xmlagg('rest\u of_your\u sql'))作为结果