webCOMAND

POSITION_IN()

Return the index of the object within a collection.

Prototype

integer POSITION_IN(cpath $cpath, cpath $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.

Folder cPath Example

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

Folder OID Example

SELECT * FROM WebPage WHERE POSITION_IN(123)

Collection Field Example

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

Collection Field Example

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