Reputation: 41
I want to know why is the metadata_getnatr
function is used with metadata_resolve
function when we are trying to read the metadata through data step functions.
For example: in the code that is covered in the link
Reproduced Here:
Example 1: Using an Object URI
data _null_;
length id $20
type $256;
rc=metadata_resolve("omsobj:Machine?@Name='bluedog'",type,id);
put rc=;
put id=;
put type=;
run;
Example 2: Using a Repository URI
data _null_;
length id $20
type $256
attr $256
value $256;
rc=metadata_resolve("omsobj:RepositoryBase?@Name='myrepos'",type,id);
put rc=;
put id=;
put type=;
n=1;
rc=1;
do while(rc>=0);
rc=metadata_getnatr("omsobj:RepositoryBase?@Name='myrepos'",n,attr,value);
if (rc>=0) then put attr=;
if (rc>=0) then put value=;
n=n+1;
end;
run;
Thanks!
Upvotes: 4
Views: 335
Reputation: 12691
I agree - the documentation here could be improved!
The first example is quite clear - provide a URI (metadata query) and return the type and Id to be used for further logic / queries.
The second example demonstrates something which is a bit of an edge case. It is using the REPO namespace (instead of the usual, SAS namespace) to return an object representing the repository (eg FOUNDATION). You may have noticed that you cannot substitue the URI with the ID from the original metadata_resolve
function (which you'd expect the example to be demonstrating, as an efficiency thing). According to the documentation, the RepositoryBase subclass inherits it's metadata id, so this may indicate why it cannot be referenced without using a URI.
In any case, to clarify the usage of metadata_resolve
:
metadata_getnatr
SAS will cache your query within the same metadata function, so unless you are going to use the same URI in more than one metadata function, you don't need to use metadata_resolve
.
Upvotes: 1