BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi guys

I have to delete an object from metadata with id "Id" (from logins dataset) and create a new one with the name "TestObject".
I did like this:

data null;
length uri $256;
rc=1;
set logins;
add_uri = "omsobj:Login?@Name='TestObject'";
del_uri = "omsobj:Login?@Id='" || trim(Id) || "'";
rc = metadata_delobj(del_uri);

if(rc<0) then do;
putlog "WARNING: Cannot delete uri: " del_uri;
end;
else do;
putlog "INFO: Deleted uri: " del_uri;
* Add a new object if deletion was succsessfull
rc=metadata_newobj("Login", add_uri, Name="TestObject");
if(rc<0) then do;
putlog "WARNING: Cannot add uri: " del_uri;
end;
else do;
putlog "INFO: Added uri: " add_uri;
end;
end;
run;

but it works not like I want.
It deletes the object and creates a new one, but with name " 0" instead of "TestObject" O_o
Can please somebody explain me why?
Probably I don't understand completely which value should have URI...
4 REPLIES 4
Cynthia_sas
Diamond | Level 26
Hi:
Perhaps the documentation will help:
http://support.sas.com/documentation/onlinedoc/91pdf/sasdoc_913/omd_ref_10177.pdf

If the documentation doesn't help, you might consider contacting Tech Support.

cynthia
deleted_user
Not applicable
Thank you, but I have already read this, and also the second part.
I have now some thoughts... I will try and post if it will be ok.
But anyway, it could be great to hear your thoughts.
Cynthia_sas
Diamond | Level 26
Hi:
My thoughts are that if I needed to write code to alter the metadata, I would call Tech Support for more help if my first attempt did not have the desired results. I'm very conservative --very conservative-- with the metadata. Of course, one of the reasons that I'm very conservative with the metadata is that I am the person who, with one JCL job, managed to delete the production load library out from under the queue of production jobs waiting to execute. (All because I did not check that there was a beginning comment in some code I was testing.)

Of course, that was when I was just starting out mumblety-mumble years ago in a mainframe shop. And there is a difference between a production load library and the metadata server. But you asked for my thoughts and my thoughts are that if I were at the point you're at, I would contact Tech Support. Certainly if you post your code and questions here, other folks might have some insight.

cynthia
RichardDeVen
Barite | Level 11

The third argument to metadata_newobj is the name, or more exactly the value of the name attribute of the new object.

 

Now look at your code.

rc=metadata_newobj("Login", add_uri, Name="TestObject");

The third argument is Name="TestObject", which is a logical evaluation whose result if false, which is numeric 0, which is auto-cast to the string "0", which becomes the new object's name.

 

The correct code would be

rc=metadata_newobj("Login", add_uri, "TestObject");

 

 

 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

Register now

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 4 replies
  • 2897 views
  • 0 likes
  • 3 in conversation