FIELDNAME function

The FIELDNAME field function returns the name of a given field.

Syntax

FIELDNAME returns the name of the field identified by source_field_reference as a character value. If the parameter identifies a nonexistent field, NULL is returned.

For example:
FIELDNAME(InputRoot.XML)
returns XML.
FIELDNAME(InputBody)
returns the name of the last child of InputRoot, which could be XML.
FIELDNAME(InputRoot.*[<])
returns the name of the last child of InputRoot, which could be XML.

This function does not show any namespace information; this must be obtained by a separate call to theFIELDNAMESPACE function.

Whereas the following ESQL sets X to "F1":
SET X [equals char] FIELDNAME(InputBody.*[<]);
the following ESQL sets Y to null:
SET Y [equals char] FIELDNAME(InputBody.F1.*[<]);
However, the following ESQL sets Z to the (expected) child of F1:
SET Z [equals char] FIELDNAME(InputBody.*[<].*[<]);
This is because F1 belongs to a namespace and needs to be explicitly referenced by, for example:
DECLARE ns NAMESPACE 'urn:nid:xxxxxx';

SET Y [equals char] FIELDNAME(InputBody.ns:F1.*[<]);
Related concepts
ESQL
Related tasks
Developing ESQL
Related reference
Syntax preference
ESQL field functions