Functions with Additional Search Options - Teradata Meta Data Services

Teradata Meta Data Services Programmer Guide

Product
Teradata Meta Data Services
Release Number
15.00
Language
English (United States)
Last Update
2018-09-28
Product Category
Teradata Tools and Utilities

Functions with Additional Search Options

The GetDestCollection, GetOrigCollection, and GetClassObjects functions will return the entire collection of objects associated with the object or class, and if a name is specified returns only the objects matching the name.

The following functions allow for further refinement of the objects returned in the collection or class. This refinement is based on matching property values in the destination or origin objects.

 

Sort List

The sortList can contain zero or more CMetaObjectKey objects. Each CMetaObjectKey identifies a property by ID or name on which to sort the returned objects. The sort key created is constructed by concatenating the property values.

The maximum size of the sort key is limited to 4096 bytes. If the sort key is greater than 4096 bytes, the key is truncated and the data may or may not come back in the desired order.

By default, the result values of a character property are sorted in ascending order, using the collating sequence in effect for the Teradata session.

To enable specifying sort by ascending or descending order, use one of the following two property values:

  • PID_SORT_ASCENDING
  • PID_SORT_DESCENDING
  • These variables are defined in metaglobals.h. To set the sort order to descending, set a CMetaObjectKey ObjectID to PID_SORT_DESCENDING and push the object on the sortList vector. For example:

    CLEARVECTOR(sortList);
    propID.SetObjectID(PID_CMN_NAME);
    sortList.push_back(propID);
    propID.SetObjectID(PID_SORT_DESCENDING);
    sortList.push_back(propID);
    result = obj.GetClassObjectsByProperty(objectList, propFilter,
    sortList, gClassID, lClassID, strObjName);
    result = obj.GetClassObjectsByProperty(objectList, propFilter, sortList, gClassID, lClassID, strObjName);

    If keys specifying both PID_SORT_ASCENDING and PID_SORT_DESCENDING are pushed on the list, the sort order will be ascending.

    Name Search

    To add a search on the name field of the objects in the collection, a character string expression can be specified in strObjName. This search will return objects which have names which contain a match of a character string pattern within the object name. The following describes the search string value:

  • The search string value can be any character string.
  • The % and _ characters may be used in any combination in the search string
  • The % (percent sign) character represents any string of zero or more arbitrary characters.
  • The _ (spacing underscore) character represents exactly one arbitrary character.
  • Any single character is acceptable in the position in which the underscore character appears, and any string of characters is acceptable as a replacement for the percent.
  • The backslash character (\) can be used as an escape character to search for the \, % or _ characters ( \\, \%, \_ ) in the name.
  • Both leading and trailing pad characters in the name field must match exactly with the search string. For example, ‘A%BC’ matches ‘AxxBC’, but not ‘AxxBΧD’, and ‘A%BΧD’ matches ‘AxxBΧD’, but not ‘AxxBC’ or ‘AxxBΧΔD’ indicates a pad character).
  • The name search in the functions in the GetClassObjects and GetClassObjectsByProperty differ by the use of the percent and underscore characters.

    In the GetClassObjects function, if the search string contains a % or _, objects are returned only if the name matches those characters exactly. For example, if the search string is “ABC_123”, the only objects returned are those with the name “ABC_123”.

    In the GetClassObjectsByProperty function, the _ (underscore) character is a wildcard character which represents one arbitrary character, so the search string “ABC_123” will return objects with the names: “ABC_123”, “ABC 123”, “ABCZ123”, and “ABC1123”. To return a match for only the object name “ABC_123”, you must use the backslash escape character in the search string “ABC\_123”.

    If a strObjName is set and search properties are set in the propFilter, the search will be performed on the name “AND” the values in the propFilter.

    The propFilter can also contain object names for searching. The differences between using the strObjName parameter and setting the object name in the propFilter are:

  • The name in the strObjName parameter is always AND’d to the values in the propFilter list. A name in the propFilter can be OR’d to other values in the propFilter.
  • The name in the strObjName parameter is always compared using the REGEX comparison operator. A name in the propFilter can be set to use any of the other comparison operators.
  • Column Filter

    Some interfaces provide a column filters parameter. This parameter provides an additional method to restrict the properties returned for an object. This will reduce the amount of data transmitted from the repository.

    The column filters parameter is a vector of type MetaObjectIDVector. Each entry in the vector provides the relative propertyID for a property in a class. A property ID can be either one of the unique properties for the class or it can be one of the common properties present in all CMetaObject objects. The common properties IDs are defined in the C++ include deck metaglobals.h and range from PID_CMN_NAME to PID_CMN_ISFROZEN.

    Due to processing requirements within MDS, the following common properties will always be fetched from the repository: PID_CMN_NAME, PID_CMN_OWNERID, PID_CMN_LOID, and PID_CMN_SECURITYPROFID.

    If the column filters parameter is an empty vector, all properties for the objects will be returned by the interface.

    If a non-empty column filters parameter is used, the properties not listed in the vector will have undefined values in the returned objects. The properties not listed will not be set up by MDS; this applies to both the unique class properties and the common properties.

    Inheritance

    A class inherits all the relationships of its superclasses. In Figure 23, there is a relationship called RelAM that has the origin class of ClassA and the destination class of ClassM. Classes that inherit from ClassA and ClassM also inherit the relationship. ClassB and ClassC objects can be origin objects in the relationship and ClassN and ClassO objects can be destination objects.

    Figure 23: Class Inheritance and Collections

    Figure 23 also shows example collections. In the examples, object A1 has collections with class M, N, and O objects using the RelAM relationship. The returnClass and allClasses parameters of GetDestCollection3 determine the class of objects that are returned. To return one specific class type, set the returnClass to this value. For example to return the collection of ClassN objects for A1, set the returnClass to the object id of ClassN. To return all destination class types, set allClasses to true. Getting the destinations objects of A1 in RelAM with allClasses set to true will return the objects M1,M2,M3,N1,N2,N3,O1,O2, and O3.