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
SAS Super FREQ
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
SAS Super FREQ
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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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