XML.Query

  • 19 July 2022
  • 1 reply
  • 52 views

This article is about the Query method of the XML internal component.

XML.Query

Executes a query that is defined in an input XML document. The structure of this XML document must comply with the Query By Form (QBF) specification described in XML Representation of Queries.

Returns XML output that contains the query results. The structure of this XML output is described here. This XML output contains ALL column values of the records exported.

Syntax

INVOKE XML.Query WITH
SELECT header-line-name DTDName
, use-io-formats UseIOFormats
, document XMLDocument
FROM table

use-io-formats := { No | Yes }

where document is the only required output column.

The optional header-line-name specifies a header line in the XML output with a DOCTYPE declaration containing this DTD Name as reference.

The optional use-io-formats determines whether the column values in the resulting XML document must be formatted according to the IO Format of the corresponding domain or not. This happens only if use-io-formats is passed with the 'Yes' value. Otherwise, date columns must obey to the format explained in help topic "XML representation of date values".

These optional output columns are case-insensitive. So are the associated pseudo-column names (DTDName, UseIOFormats).

The required document contains the input XML document compliant with the QBF specification.

If the SELECT query has an empty result set (= no rows are retrieved), there is no XML output. Otherwise, each record retrieved by the SELECT query returns an XML document.

If the query condition specified in the input XML document results in no records, then the resulting XML output contains only the root element and no row elements.

Conditions

The SELECT statement must comply with the following conditions:

  • For each parameter value, the parameter name must be specified.
  • Parameters have constant values.
  • If the SELECT results in no row, there is no XML output.
  • Every record retrieved by the SELECT results in an XML output document.
  • If the query condition specified in the input XML document results in no records, then the resulting XML output contains only the root element and no row elements.

1 reply

Userlevel 2
Badge +2

fyi a working example:

INVOKE XML.Query WITH
SELECT
'Yes' "UseIOFormats"
, '
<Query>
<Table Name="T_DOMAIN">
<Column Name="DOMAIN_NAME" Condition="TW%"
Order-by-seqno="1" Order-by-direction="DESCENDING"/>
<Column Name="DATATYPE" Condition="NUMBER"
Order-by-seqno="2" Order-by-direction="DESCENDING"/>
</Table>
</Query>' "XMLDocument"

Result:

-----report on script no. 1
<Domains documentName="Domains">
<T_DOMAIN DOMAIN_NAME="TWI_INT_8" SUPER_DOMAIN="" DATATYPE="NUMBER" TOTAL_LENGTH="8" LENGTH_AFTER_PERIOD="0" F_DATATYPE="INT" F_TOTAL_LENGTH="8" F_LENGTH_AFTER_PERIOD="0" DISPLAY_LENGTH="" UPPERCASE="N" FIXED_LENGTH="N" IS_SEQNO="N" DEF_VALUE="" RANGE_LOW="" RANGE_HIGH="" HELP_TEXT="" IOFORMAT="" DBFORMAT="" DESCR="Domain is used by USoft Production." PERC_FULL="" CREATED_BY="ROBERT10 CREATED_ON=" 12-NOV-2020 10:28:43" CHANGED_BY="ROBERT10" CHANGED_ON="12-NOV-2020 10:28:43" SEQNO_COMPONENT="" INTERFACE="N" MODULE="" INTERFACE_CORRECT="Y" REGEXP=""/>
<T_DOMAIN DOMAIN_NAME="TWI_INT_4" SUPER_DOMAIN="" DATATYPE="NUMBER" TOTAL_LENGTH="4" LENGTH_AFTER_PERIOD="0" F_DATATYPE="INT" F_TOTAL_LENGTH="4" F_LENGTH_AFTER_PERIOD="0" DISPLAY_LENGTH="" UPPERCASE="N" FIXED_LENGTH="N" IS_SEQNO="N" DEF_VALUE="" RANGE_LOW="" RANGE_HIGH="" HELP_TEXT="" IOFORMAT="" DBFORMAT="" DESCR="Domain is used by USoft Production." PERC_FULL="" CREATED_BY="ROBERT10 CREATED_ON=" 12-NOV-2020 10:28:43" CHANGED_BY="ROBERT10" CHANGED_ON="12-NOV-2020 10:28:43" SEQNO_COMPONENT="" INTERFACE="N" MODULE="" INTERFACE_CORRECT="Y" REGEXP=""/>
<T_DOMAIN DOMAIN_NAME="TWI_INT_2" SUPER_DOMAIN="" DATATYPE="NUMBER" TOTAL_LENGTH="2" LENGTH_AFTER_PERIOD="0" F_DATATYPE="INT" F_TOTAL_LENGTH="2" F_LENGTH_AFTER_PERIOD="0" DISPLAY_LENGTH="" UPPERCASE="N" FIXED_LENGTH="N" IS_SEQNO="N" DEF_VALUE="" RANGE_LOW="" RANGE_HIGH="" HELP_TEXT="" IOFORMAT="" DBFORMAT="" DESCR="Domain is used by USoft Production." PERC_FULL="" CREATED_BY="ROBERT10 CREATED_ON=" 12-NOV-2020 10:28:43" CHANGED_BY="ROBERT10" CHANGED_ON="12-NOV-2020 10:28:43" SEQNO_COMPONENT="" INTERFACE="N" MODULE="" INTERFACE_CORRECT="Y" REGEXP=""/>
<T_DOMAIN DOMAIN_NAME="TWI_INT_1" SUPER_DOMAIN="" DATATYPE="NUMBER" TOTAL_LENGTH="1" LENGTH_AFTER_PERIOD="0" F_DATATYPE="INT" F_TOTAL_LENGTH="1" F_LENGTH_AFTER_PERIOD="0" DISPLAY_LENGTH="" UPPERCASE="N" FIXED_LENGTH="N" IS_SEQNO="N" DEF_VALUE="" RANGE_LOW="" RANGE_HIGH="" HELP_TEXT="" IOFORMAT="" DBFORMAT="" DESCR="Domain is used by USoft Production." PERC_FULL="" CREATED_BY="ROBERT10 CREATED_ON=" 12-NOV-2020 10:28:43" CHANGED_BY="ROBERT10" CHANGED_ON="12-NOV-2020 10:28:43" SEQNO_COMPONENT="" INTERFACE="N" MODULE="" INTERFACE_CORRECT="Y" REGEXP=""/>
</Domains>
-----end of report on script no. 1

 

Reply