3

我有一些名称相同的存储过程。要确定当前正在运行的进程,我需要知道元数据中存储进程的 id。我可以在某处检索 STP-id 吗?我找不到包含 id 的变量。我只找到了 symget('sysjobid'); 它返回 unix-processid,而不是存储进程的 id。

典型的存储进程 ID 如下所示:A5DF0R0G.B80001L7

我需要知道正在运行的进程中的 id,以便从元数据中检索进程的某些属性。
任何其他在元数据中准确识别进程的解决方案也将受到欢迎,但我不能使用他的名字,因为它可能会针对不同的进程发生多次。

例如:

put 'name:' &_program; /*this already works and returns the name of the stored process*/
put 'id:' ?; /*need to know the id of the process, because name is not distinct*/
4

2 回答 2

4

现在我看它实际上很容易。

我在“我的文件夹”文件夹中创建了这个示例 STP(名为“Doms Hello World”)。

data _temp;
X = "HELLO WORLD";
path = "&_PROGRAM";
format type ID $200.;
rc= metadata_pathobj("",path,"StoredProcess",type,ID);
run;

proc print data=_temp noobs;
run;

您可以使用该metadata_pathobj()函数通过路径获取元素的 ID 和 TYPE。

这返回

X            path                                               type            ID                  rc
HELLO WORLD /User Folders/dpazzula/My Folder/Doms Hello World   ClassifierMap   A5XQ9K3Z.BA0002BQ   1

在 EG 中和通过 Web 应用程序。

于 2015-07-15T16:56:46.730 回答
0

我认为存储过程没有 ID,但它的位置和名称是唯一的。

用户_PROGRAM 宏变量来确定正在运行的存储过程。它将具有“/SAS 文件夹/存储过程文件夹/存储过程名称”的格式。

存储过程的 A5DF0R0G.B80001L7 ID 之类的东西在运行 IOM 应用程序时很有用,但我认为在确定什么存储过程创建了一些东西以及它当时保存在哪里时,它不会那么有用,所以我会选择“_程序”。

如果您在 ID 之后仍然使用此代码(来源: https: //support.selerity.com.au/entries/23169736-Example-Data-Step-View-of-Stored-Procedures-in-Metadata):

 ******************************************************************************
* Purpose: Create a dynamic view of Stored Procedures registered in Metadata
* Notes  : You must establish a Metadata connection prior to running
******************************************************************************;
data work.stplist(drop=_: label="SAS Stored Process List") /     view=work.stplist;
 length id $17 _uri name description _modified _created location _location    $256;
  length created modified 8;
  format created modified datetime.;
  label id="Metadata ID"
        name="Stored Process Name"
        description="Description"
        location="Folder Location"
        created="Created"
        modified="Last Modified";
  _nobj=1;
  _n=1;
  call missing(id, _uri, name, description, _modified, _created, _location);
  do while(_n le _nobj);
    _nobj=metadata_getnobj("omsobj:ClassifierMap?@PublicType='StoredProcess'",_n,_uri);
    _rc=metadata_getattr(_uri,"Id",id);
    _rc=metadata_getattr(_uri,"Name",name);
    _rc=metadata_getattr(_uri,"Desc",description);
    _rc=metadata_getattr(_uri,"MetadataCreated",_created);
    _rc=metadata_getattr(_uri,"MetadataUpdated",_modified);
    created=input(_created,anydtdtm.);
    modified=input(_modified,anydtdtm.);
    * Get folder object the current STP is in *;
    _rc=metadata_getnasn(_uri,"Trees",1,_uri);
    * Get folder name the current STP is in *;
    _rc=metadata_getattr(_uri,"Name",location);
    _tree=1;
    * Loop up the folder hierarchy *;
    do while (_tree>0);
      * Get the parent folder object *;
      _tree=metadata_getnasn(_uri,"ParentTree",1,_uri);
      if _tree > 0 then do;
        * If there was a parent folder, get the name *;
        _rc=metadata_getattr(_uri,"Name",_location);
        * Construct the path *;
        location=catx('/',_location,location);
      end;
    end; * Folder Hierachy *;
    location = '/'||location;
    output;
    _n=_n+1;
  end;
run;

问候, 瓦西里

于 2015-07-15T16:36:13.170 回答