METADATA_GETNOBJ Function

Returns the nth object that matches the specified URI.

Syntax

rc = METADATA_GETNOBJ(uri, n, nuri);

Required Arguments

uri (in)
specifies a Uniform Resource Identifier.
n (in)
specifies a numeric index value that indicates which row to return from the array; see Array Parameters.
nuri (out)
returns the URI of the nth object that matches the input URI or matches a subtype object of the input URI.

Return Values

n
The number of objects and subtype objects that match the specified URI.
-1
Unable to connect to the metadata server.
-3
No objects match the specified URI.
-4
n is out of range.

Examples

Example 1: Determining How Many Machine Objects Exist

options metaserver="a123.us.company.com"
	metaport=8561
	metauser="myid"
	metapass="mypassword"
	metarepository="myrepos";

data _null_;
    length uri $256;
    nobj=0;
    n=1;
   
    /* Determine how many machine objects are in this repository. */

    nobj=metadata_getnobj("omsobj:Machine?@Id contains '.'",n,uri);
    put nobj=;   /* Number of machine objects found. */
    put uri=;    /* URI of the first machine object. */

run;

Example 2: Looping Through Each Repository on a Metadata Server

options metaserver="a123.us.company.com"
	metaport=8561
	metauser="myid"
	metapass="mypassword"
	metarepository="myrepos";

data _null_;
    length uri $256;
    nobj=1;
    n=1;
   
    /* Determine how many repositories are on this server. */

    do while(nobj >= 0);

        nobj=metadata_getnobj("omsobj:RepositoryBase?@Id contains '.'",n,uri);
        put nobj=;   /* Number of repository objects found. */
        put uri=;    /* Nth repository.                     */
        n=n+1;
    end;
run;