webCOMAND

.POSITION_IN()

Return the index of an object within a collection where the object is not the main object in the FROM clause, but instead referenced through a field.  An object can be referenced through multiple fields using dot-notation.  For example, Parent.Parent.POSITION_IN(/Folder).

To access the position of an object in the FROM clause, use function POSITION_IN().

Prototype

integer .POSITION_IN(cpath $cpath, string $field = NULL)

Parameters

  • cpath - cPath, OID, DOID (ie. 123D) or UUID that references a:
    • Folder - If a folder or object that extends folder is specified and no field parameter is specified, the Folder's Contents field will be assumed.
    • Object - If a non-folder object is specified, then the field must be specified.
  • field - Optional Identifier of an ordered collection field, which is required when the cpath parameter references an object that is not a Folder.

Return

An integer that represents the object's index into the ordered collection.  If the object is not in the collection, NULL is returned, which can be useful when testing for an object's membership in a specific field in a WHERE clause or cPath filter.

Examples

Folder cPath Example

SELECT * FROM WebPage ORDER BY Parent.POSITION_IN(/Website/Content)

Folder OID Example

SELECT * FROM WebPage WHERE Parent.POSITION_IN(123)

Collection Field in cPath Example

SELECT * FROM WebPage ORDER BY Parent.POSITION_IN([:Menu AND OID=456].WebPages)

Collection Field as Parameter Example

SELECT * FROM WebPage ORDER BY Parent.POSITION_IN(456, WebPages)

Related

POSITION_IN()