Getting Collections of Object Keys - Teradata Meta Data Services

Teradata Meta Data Services Programmer Guide

Product
Teradata Meta Data Services
Release Number
15.00
ft:locale
en-US
ft:lastEdition
2018-09-28
Product Category
Teradata Tools and Utilities

Getting Collections of Object Keys

This section shows example code to get collections of object keys. The example code uses:

  • CMetaObject::GetDestCollectionKeys
  • CMetaObject::GetOrigCollectionKeys
  • The example code also shows how to iterate through the returned vector of object keys.

    ////////////////////////////////////////////////////////////////////
    // GetDestCollKeys function
    // Reads and print a collection of keys. 
    //
    // Example of using the CMetaObject::GetDestCollectionKeys function
    ////////////////////////////////////////////////////////////////////
    HRESULT GetDestCollKeys()
    {
    	MetaObjectKeyVector objectKeys;
    	HRESULT			result = S_OK; 
    	CMetaObject		obj;     
     
    	obj.SetClassGUID(CLSGUID_AutoDiv);
    	obj.SetObjectName(_T("AmericanAutos"));
    	if (SUCCEEDED(result = obj.ReadObject()))
    	{
    		// Get collection of object keys (name and objectid)
    		// of all Autos of AmericanAutos
    		result = obj.GetDestCollectionKeys(objectKeys, 
    			RELGUID_DivMakesAutos);
    		if (SUCCEEDED(result))
    		{
    			cout << endl;
    			cout << ">>> Collection of object keys (name and objectid) ";
    			cout << endl;
    			cout << ">>> of all Autos of AmericanAutos" << endl;
    			PrintKeyList(objectKeys);
    			CLEARVECTOR(objectKeys);
    		}
    	}
    	return(result);
    }
     
    /////////////////////////////////////////////////////////////////////
    // GetOrigCollKeys function
    // Reads and print a collection of keys. 
    //
    // Example of using the CMetaObject::GetOrigCollectionKeys function
    /////////////////////////////////////////////////////////////////////
    HRESULT GetOrigCollKeys()
    {
    	MetaObjectKeyVector objectKeys;
    	HRESULT			result = S_OK; 
    	CMetaObject		obj;     
     
    	obj.SetClassGUID(CLSGUID_Auto);
    	obj.SetObjectName(_T("Yearling"));
    	if (SUCCEEDED(result = obj.ReadObject()))
    	{
    		// Get collection of all Auto Divisions of Yearling
    		result = obj.GetOrigCollectionKeys(objectKeys, 
    			RELGUID_DivMakesAutos);
    		if (SUCCEEDED(result))
    		{
    			cout << endl;
    			cout << ">>> Collection of all Auto Divisions of  Yearling" << endl;
    			PrintKeyList(objectKeys);
    			CLEARVECTOR(objectKeys);
    		}
    	}
    	return (result);
    }