Declare a variable in query prolog.
A VarDecl
declares a variable along with an optional type
information in the prolog. It contains the keywords declare
variable
, followed by the variable name. An optional type information is
introduced by the keyword as
. The final keyword
external
is mandatory and indicates that the value of the variable
will be provided by the external environment of the query. A type error is
raised if in the dynamic phase of query processing the value is not of the
specified type. If a variable declaration does not include a type declaration,
then item()*
is assumed.
Please note that a variable declaration differs from a variable binding
as performed by for
and let
in FLWOR expressions. A
variable declaration always refers to the declaration of a variable in a
prolog, while a variable binding binds a variable to a value in a query
expression and does not make the variable visible in the importing module.
This variable declaration declares the variable
$x
as of type integer:
declare variable $x as xs:integer external
This variable declaration declares the variable
$x
. As type item()*
is assumed:
declare variable $x external
The following construct(s) refer to this construct:
This construct is also related to the following construct(s):
See also the discussion of external variables in the section
The _execute
command of the X-Machine programming documentation.