Oracle 11g に次の表があります。
CREATE TABLE jason_xml(
id NUMBER(5) PRIMARY KEY,
xml_content XMLTYPE
)tablespace WD_T
xml_content 列内に XML ドキュメントがあります。
<results>
<return>
<actualtime>0.0</actualtime>
<billingamount>0.0</billingamount>
<buildlisttext>
<buildnumber>0</buildnumber>
<completiondate>2007-04-10T12:36:00+02:00</completiondate>
<componentid>0</componentid>
<containsrecipients>false</containsrecipients>
<containsrecipientshasbeenset>true</containsrecipientshasbeenset>
<costamount>0.0</costamount>
<createdate>2006-11-20T17:10:02+01:00</createdate>
<createdbysystemuserid>89198</createdbysystemuserid>
<currentownersystemuserid>12122</currentownersystemuserid>
<currentownerusergroupid>0</currentownerusergroupid>
<customerid>95</customerid>
<description>From: Ricky Bolton</description>
</buildlisttext>
</return>
<return>
<actualtime>0.0</actualtime>
<billingamount>0.0</billingamount>
<buildlisttext>
<buildnumber>0</buildnumber>
<completiondate>2007-04-10T12:36:00+02:00</completiondate>
<componentid>0</componentid>
<containsrecipients>false</containsrecipients>
<containsrecipientshasbeenset>true</containsrecipientshasbeenset>
<costamount>0.0</costamount>
<createdate>2006-11-20T17:10:02+01:00</createdate>
<createdbysystemuserid>89198</createdbysystemuserid>
<currentownersystemuserid>12122</currentownersystemuserid>
<currentownerusergroupid>0</currentownerusergroupid>
<customerid>95</customerid>
<description>From: Derek Trotter</description>
</buildlisttext>
</return>
</results>
jason_xml テーブル列内からこのドキュメントをクエリして、結果を次のように表示しようとしています。
|billingamount|Description|
|0.0 |From: Ricky Bolton|
|0.0 |From: Derek Trotter|
私は Oracle API の方向性を指摘されましたが、API を読むのが苦手で、これは非常に不十分に書かれていることがわかりました。このページで定義されている多くの演算子を試しましたが、うまくいきませんでした:
http://docs.oracle.com/cd/B28359_01/appdev.111/b28369/xdb04cre.htm#BABDGFFH
私はこれまでに取得しましたが、PL/SQL 開発者で「無効な識別子」を取得し続けます。私はおそらくこれで完全に間違っていることを知っているので、誰かがポインタ/解決策を持っていますか?
SELECT extractValue(OBJECT_VALUE, 'results/return/buildlisttext/description') "DESCRIPTION" FROM jason_xml x WHERE xmlexists('results/return/buildlisttext/description' PASSING OBJECT_VALUE);
私はPHPでMySQLユーザーを使用しており、そのテクノロジーの組み合わせでこれを簡単に行うことができますが、残念ながら私は仕事でOracle 11gを使用する必要があります.
どんな助けでも大歓迎です。