Veröffentlicht am :

Extraction des Quellcodes von Stored Processes (SAS Metadaten)

Dieser Code ist auch verfügbar auf: English Español Français
Attention : Dieser Code erfordert Administratorrechte.
Das Skript verwendet die SAS© Open Metadata Interface (metadata_*-Funktionen), um 'ClassifierMap'-Objekte zu suchen, die Stored Processes entsprechen. Es durchläuft dann die zugehörigen Notizen, um die Notiz namens 'SourceCode' zu finden und den gespeicherten Text zu extrahieren. Das Skript enthält auch eine auskommentierte Logik zur direkten Änderung und Aktualisierung dieses Quellcodes in den Metadaten. Hinweis: Dieses Skript ist spezifisch für die SAS© 9 Metadatenarchitektur und gilt nicht für nativen SAS© Viya (SAS© Content) Inhalt.
Datenanalyse

Type : EXTERNE


Die Daten werden dynamisch vom SAS Metadatenserver über Funktionsaufrufe (metadata_resolve, metadata_getnobj usw.) extrahiert.

1 Codeblock
DATA STEP
Erklärung :
DATA _NULL_ Schritt, der über Metadatenobjekte iteriert, um den Quellcode von Stored Processes zu extrahieren und anzuzeigen.
Kopiert!
1DATA _null_;
2 
3/* Initialize the variables. */
4 
5 LENGTH program newprog $ 32587 type id $ 50
6 sp_uri $ 38 note_uri $ 34 note_name $ 255;
7 call missing(of _character_);
8 
9/* Define a query that will return only Stored Process */
10/* objects with an associated source code TextStore object. */
11 
12sp_obj="omsobj:ClassifierMap?ClassifierMap[ @PublicType='StoredProcess'][Notes/TextStore[ @Name='SourceCode']]";
13 
14/* Count how many objects meet that query. */
15 
16 sp_count=metadata_resolve(sp_obj,type,id);
17 
18/* If some exist, gather their information. */
19 IF sp_count > 0 THEN DO i=1 to sp_count;
20 
21/* Get the URI for each Stored Process object found that matches the query. */
22 rc=metadata_getnobj(sp_obj,i,sp_uri);
23 
24/* Count how many notes are associated with the object. */
25 note_count=metadata_getnasn(sp_uri,"Notes",1,note_uri);
26 
27/* If some exist, get their attributes. */
28 IF note_count > 0 THEN DO j=1 to note_count;
29 /* get the URI of the note. */
30 rc=metadata_getnasn(sp_uri,"Notes",j,note_uri);
31 /* get the name of the note. */
32 rc=metadata_getattr(note_uri,"Name",note_name);
33 
34/* If the Note's name is "SourceCode", get it's "StoredText" attribute. */
35 IF note_name="SourceCode" THEN DO;
36 rc=metadata_getattr(note_uri,"StoredText",program);
37 put;
38 put note_uri=; /* Print the URI to the Log */
39 put;
40 put program=; /* Print the program to the log. */
41 /* Optional find and replace code. replace old_text */
42 /* and new_text with the word to replace. */
43 *newprog=tranwrd(program,'old_text','new_text');
44 *rc=metadata_setattr(note_uri,"StoredText",newprog);
45 END;
46 END;
47 END;
48RUN;
Dieses Material wird von We Are Cas "wie besehen" zur Verfügung gestellt. Es gibt keine ausdrücklichen oder stillschweigenden Garantien hinsichtlich der Marktgängigkeit oder Eignung für einen bestimmten Zweck in Bezug auf die hierin enthaltenen Materialien oder Codes. We Are Cas ist nicht verantwortlich für Fehler in diesem Material, wie es jetzt existiert oder existieren wird, noch bietet We Are Cas technischen Support dafür an.
Urheberrechtsinformationen : Author: Greg Wootton Date: 03DEC2018