Previous Page | Next Page

Metadata API Class

_SET_PRIMARY_REPOSITORY_



Attaches to a primary metadata repository
Category: Repository Methods

Syntax
Parameters
Details
Using _SET_PRIMARY_REPOSITORY_
Examples
Example 1: Access a Primary Metadata Repository
Example 2: Using _GET_METADATA_ to list secondary repositories
See Also

Syntax

CALL SEND(i_api, '_SET_PRIMARY_REPOSITORY_', l_rc, l_meta, repos_type, repos_id, l_meta2, <already>);

Parameters

Parameter Type Description
i_api Class specifies the passed instance of METAAPI.CLASS. See Using the Metadata API Class.
l_rc N specifies the return codes for the method. A nonzero code indicates failure and means that l_rc is an error list identifier. For the error list format, see Error Codes.
l_meta L specifies the passed metadata property list for the primary repository that is to be set.
repos_type C specifies the passed repository type ID of the primary metadata repository that is to be set.
repos_id C specifies the returned repository ID for the primary metadata repository that was set. For details about the repository ID parameter, see Identifying Metadata.
l_meta2 L specifies the returned metadata property list for the repository that was set.
already N specifies the passed indicator. Optional. Specifies whether the repository to be set is already accessible.


Details

l_rc

specifies the return codes for the method.

Note:   Be sure to check the return code for this method. Do not continue if the method fails.   [cautionend]

l_meta

specifies the passed metadata property list for the primary repository that is to be set.

From the list of all possible properties for the metadata repository type that is specified in the repos_type parameter, you need only to pass those properties that are required to allocate a SAS libname for the repository. See the following Usage notes.

repos_type

specifies the passed repository type ID of the primary metadata repository that is to be set.

To identify the primary repository type ID for a given SAS application, see its metadata type documentation. For example, in SAS/Warehouse Administrator, the primary repository type ID is WHDWENV for the environment repository.

repos_id

specifies the returned repository ID for the primary metadata repository that was set. Use this ID as the REPOSID part of the metadata identifier in subsequent methods that access metadata in this repository.

l_meta2

specifies the returned metadata property list for the repository that was set. Includes the general, identifying information for that repository. Use this list with subsequent calls, such as _GET_METADATA_, to retrieve more information about the primary repository. See Example 2.

already

specifies the passed indicator. Optional. Specifies whether the repository that is to be set is accessible.

0 -- (default) repository is not accessible. Perform the process to gain access to the repository.

1 -- repository is accessible.

A repository might already be accessed for several reasons. If you know that the repository is already accessed, this indicator can be set to 1 to indicate that fact. Note that you should use this parameter with caution because possible future changes to a metadata repository structure might cause incorrect results.

Note:   Mixed usage (both 0 and 1) of the already parameter during a single execution of an application is strongly discouraged. All calls to _SET_PRIMARY_REPOSITORY_ during a single execution should use a single value, either 0 or 1.   [cautionend]


Using _SET_PRIMARY_REPOSITORY_

Primary and secondary repositories are discussed in Metadata Repositories.

The example shows how to attach to the sample primary repository (a warehouse environment called Sample Demo) that is shipped with SAS/Warehouse Administrator.

In the example, repos_type is set equal to WHDWENV because WHDWENV is the type ID of a SAS/Warehouse Administrator environment repository.

The documentation for the WHDWENV type describes only one property that is needed for a SAS libname statement--LIBRARY. The LIBRARY property, in turn, has the properties of the WHLIBRY metadata type. The documentation for the WHLIBRY type describes several properties that might be needed in a SAS libname statement--ENGINE, LIBREF, OPTIONS, and PATH.

To access a local metadata repository of type WHDWENV, the l_meta list only needs to include the ENGINE, PATH, and OPTIONS properties of the LIBRARY property, as shown in the example.

Once you have attached to the primary repository, you can use the _GET_METADATA_ method to return the list of possible secondary repositories. Specify the REPOSITORIES property in the l_meta list, and use the returned metadata identifier from the _SET_PRIMARY_REPOSITORY_ method, as shown in Using _GET_METADATA_ to list secondary repositories.


Examples


Example 1: Access a Primary Metadata Repository

   /* 
    * Access the sample primary metadata repository
    * that is shipped with SAS/Warehouse Administrator, which is 
    * a warehouse environment called 'Sample Demo.' 
    */ 
path="!SASROOT\whouse\dwdemo\_master"; 
repos_type='WHDWENV'; 
   /* 
    *  Insert the Location information into 
    *  the metadata list with a name of LIBRARY. 
    */ 
l_inmeta=makelist(); 
l_lib=makelist(); 
l_inmeta=insertl(l_inmeta,l_lib,-1,'LIBRARY'); 
   /* 
    *  Use the default Libname Engine 
    *  to access a Local Path. 
    */ 
l_lib=insertc(l_lib,' ',-1,'ENGINE'); 
l_path=makelist(); 
l_lib=insertl(l_lib,l_path,-1,'PATH'); 
l_opts=makelist(); 
l_lib=insertl(l_lib,l_opts,-1,'OPTIONS'); 
l_path=insertc(l_path,path,-1); 
   /* 
    *  Set the primary repository. If a bad return code 
    *  is returned, then you cannot continue. 
    */ 
call send(i_api,'_SET_PRIMARY_REPOSITORY_',
l_rc,l_inmeta,repos_type,primary_repos_id,l_meta); 
l_inmeta=dellist(l_inmeta,'Y'); 
if l_rc = 0 then do; 
   /* 
    *  Accessed the primary repository correctly. 
    */ 


Example 2: Using _GET_METADATA_ to list secondary repositories

   /*                                                                     
    * Get the list of all repositories under 
    * the primary repository                                                      
    * l_meta is l_meta returned from
    *  _SET_PRIMARY_REPOSITORY_.
    */
 l_reps=makelist();                                                     
 l_meta=setniteml(l_meta,l_reps,'REPOSITORIES');                        
 call send(i_api,'_GET_METADATA_',l_rc,l_meta);
                           
   /* returns list: */
 l_meta=(ID='A0000001.WHDWENV.A0000001'
             NAME='Warehouse Administrator' 
             DESC='Sample Demo Warehouse Environment.'

            REPOSITORIES=(
                (ID='A0000001.WHDW.A000000E'
                 NAME='Marketing Campaigns Data Warehouse'
                 DESC='Sample Data Warehouse.'
                 )[2455]
               )[2201] 
             )[2271]


See Also

_SET_SECONDARY_REPOSITORY_

Previous Page | Next Page | Top of Page