3

同じ名前のストアド プロセスがいくつかあります。現在実行中のプロセスを特定するには、メタデータに保存されているプロセスの ID を知る必要があります。どこかで STP-id を取得できますか? ID を保持する変数が見つかりませんでした。symget('sysjobid'); しか見つかりませんでした。これは、ストアド プロセスの ID ではなく、unix-processid を返します。

通常、ストアド プロセス 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

I don't think a stored process has an ID, but it is unique in terms of its location and name.

User _PROGRAM macro variable to determine what stored procedure is running. It will have a format of "/SAS Folder/Stored Procedure Folder/Stored Procedure Name".

Something like A5DF0R0G.B80001L7 ID of the stored procedure useful when running IOM applications, but I don't think it would be that useful when it comes determining what stored procedure created something and where it was saved at the time, so I would go with "_PROGRAM".

In case you after the ID anyways, use this code (credit: 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;

Regards, Vasilij

于 2015-07-15T16:36:13.170 に答える