XMLTEXT

XMLTEXT 関数は、string-expression の値を含む XML 値を戻します。

構文図を読む構文図をスキップする
>>-XMLTEXT--(--string-expression--)----------------------------><

string-expression
組み込み文字ストリングまたは組み込みグラフィック・ストリングの値を戻す式。 CHAR または VARCHAR ビット・データであってはなりません。

この関数の結果は XML 値です。ストリング式 がヌルになる可能性がある場合は、結果もヌルになる可能性があります。ストリング式 がヌルの場合は、結果は NULL 値になります。string-expression の結果が空ストリングの場合、結果値は空テキストです。

  • 単純な XMLTEXT 照会を作成します。
      VALUES (XMLTEXT (
                'The stock symbol for Johnson&Johnson is JNJ.'))

    この照会は、以下の直列化された結果を生成します。

    The stock symbol for Johnson&amp;Johnson is JNJ.
    「&」記号は、テキストが直列化されるときには「&amp;」にマップされることに注意してください。
  • XMLTEXT を XMLAGG と共に使用して、混合の内容を構成します。表 T の内容が以下のようであるとします。
  • SEQNO  PLAINTEXT                                                     EMPHTEXT
    -----  ----------------------------------------------------------    ----------
    1      This query shows how to construct                             mixed content
    2       using XMLAGG and XMLTEXT. Without                            XMLTEXT
    3      , XMLAGG will not have text nodes to group with other nodes,  mixed content
           therefore, cannot generate             
    SELECT XMLELEMENT(NAME "para", 
                  XMLAGG(XMLCONCAT(
                                     XMLTEXT(PLAINTEXT),
                                     XMLELEMENT(
                                          NAME "emphasis", EMPHTEXT))
                           ORDER BY SEQNO), '.') AS "result"
      FROM T
    この照会は下記の結果を生成します。
    result
    ------------------------------------------------------------------------------
    <para>This query shows how to construct <emphasis>mixed content</emphasis>
    using XMLAGG and XMLTEXT. Without <emphasis>XMLTEXT</emphasis>, XMLAGG
    will not have text nodes to group with other nodes, therefore, cannot generate
    <emphasis>mixed content</emphasis>.</para>