XML SQLクエリを作成しましたが、XMLヘッダーを追加する際の解決策を見つけるのは難しいです(下記参照)。返されたデータベーステーブルのすべての生産レコードについて、親ヘッダ< メッセージ>タグとそのメッセージタグ内にある必要があります。< messageSequenceId>レコード数(最初の生産レコードの場合は1、2番目の生産レコードの場合は1)生産記録など...)。SQL XML XMLELEMENT - ルートヘッダーをより多く手に入れよう
配信タグ< 配信>は先頭に一度だけ表示され、あまりにも< /デリバリー>タグトップでフィニッシュしています。
また、出力の最後にタグと終了タグを持つ< AV-XMLがあります。
次の出力の例を参照してください。私はプログラムを終了するためにこれらを必要とします。
私はどんな返事でも前もってありがとうございます。 SQLクエリは、以下の通りです
<?xml version="1.0" encoding="UTF-8"?>
<AV-XML xmlns="http://www.iceservices.com/0.7/AV-XML" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.iceservices.com/0.7/AV-XML AV-XML.xsd">
<delivery>
<supplierType>ADMIN-AGENCY</supplierType> -- this is hard coded
<supplierId>GEMA</supplierId> -- this is hard coded
<supplierName>Gesellschaft für musikalische Aufführungs- und mechanische</supplierName> -- this is hard coded
<supplierContactPerson>Jens Kindermann</supplierContactPerson> -- this is hard coded
<recieverContactPerson>n.n.</recieverContactPerson> -- this is hard coded
<format>AV-XML</format> -- this is hard coded
<versionId>0.7</versionId> -- this is hard coded
<creationDateTime>2016-03-09T12:24:46+01:00</creationDateTime>
<deliveryNo>201603091224460100</deliveryNo>
<otherInformation>MIGRATION FIRST DELIVERY</otherInformation> -- this is hard coded
</delivery>
<message> -- a message tag for each production record
<messageSequenceId>1</messageSequenceId>
<messageType>NEW</messageType> -- this is hard coded
<otherInformation>MIGRATION FIRST DELIVERY</otherInformation> -- this is hard coded
<production>
production XML records information that I have already done in my query----------
<production>
</message>
</AV-XML>
、データベースのバージョンは11gリリース1
select XMLROOT(
xmlagg(XMLElement("Production" -- start level 1 tag for production
,XMLElement("prodCategoryType",prod.production_type)
,XMLElement("prodStatusType",prod.dn_prst_status)
,XMLElement("prodActive",'true')
,XMLElement("prodCueStatusType",decode(prod.music_content_indicator,'Y','YES','NO'))
,(select XMLAGG(XMLElement("Cue" -- start level 2 tag cue
,XMLElement("cueId", rownum)
,XMLElement("cueStatusType", cc.dn_ccst_status)
,XMLElement("cueCupType", 'NULL')
,XMLElement("cueType", 'NULL')
,XMLElement("cueOriginType", cc.gc_origin_of_cue_code)
)
) -- end level 2 tag cue
from prblk.creation_components cc
where cc.prod_cre_surr_id = prod.cre_surr_id
) ,
XMLElement("endofproduction", prod.production_source)
) -- end level 1 tag for production
) -- xmllag for production
, version '1.0'
) -- XMLROOT
AS XMLRESULT
FROM prblk.productions prod
where prod.cre_surr_id in (1753959927,1753959929)
で、現在の出力は以下の通りです。
<?xml version="1.0"?>
<Production>
<prodCategoryType>EPI</prodCategoryType>
<prodStatusType>5</prodStatusType>
<prodActive>true</prodActive>
<prodCueStatusType>YES</prodCueStatusType>
<Cue>
<cueId>1</cueId>
<cueStatusType>2a</cueStatusType>
<cueCupType>NULL</cueCupType>
<cueType>NULL</cueType>
<cueOriginType/>
</Cue>
<Cue>
<cueId>2</cueId>
<cueStatusType>2a</cueStatusType>
<cueCupType>NULL</cueCupType>
<cueType>NULL</cueType>
<cueOriginType/>
</Cue>
<Cue>
<cueId>3</cueId>
<cueStatusType>2a</cueStatusType>
<cueCupType>NULL</cueCupType>
<cueType>NULL</cueType>
<cueOriginType/>
</Cue>
<endofproduction>AP</endofproduction>
</Production>
<Production>
<prodCategoryType>EPI</prodCategoryType>
<prodStatusType>5</prodStatusType>
<prodActive>true</prodActive>
<prodCueStatusType>YES</prodCueStatusType>
<Cue>
<cueId>1</cueId>
<cueStatusType>2a</cueStatusType>
<cueCupType>NULL</cueCupType>
<cueType>NULL</cueType>
<cueOriginType/>
</Cue>
<Cue>
<cueId>2</cueId>
<cueStatusType>2a</cueStatusType>
<cueCupType>NULL</cueCupType>
<cueType>NULL</cueType>
<cueOriginType/>
</Cue>
<endofproduction>AP</endofproduction>
</Production>
このデータは、XMLを作成した瞬間に入手できますか?現時点で使用しているクエリを表示して、クエリが出てきたXMLを正確に表示してください。 – Shnugo
あなたのRDBMS(製品とバージョン)を指定してくださいXMLは**実際のソフトウェア(SQL Server、Oracle、MySql ...)に非常に依存します** – Shnugo
私はクエリ、データベースバージョン、クエリ –