1. Trang chủ
  2. » Công Nghệ Thông Tin

SAS/Warehouse Administrator 2.3 Metadata API- P56 pptx

5 174 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 5
Dung lượng 452,65 KB

Nội dung

272 273 APPENDIX 1 Sample Metadata API Code Appendix Overview 273 Read Metadata Code Sample 273 Write Metadata Code Sample 277 Appendix Overview This appendix contains SCL code that uses the metadata API to access SAS/Warehouse Administrator metadata. For longer examples, see the sample metadata API applications in the SAMPSIO.DWADDIN catalog. That catalog includes the BLDPAGE program, which reads metadata and outputs it in HTML format. Read Metadata Code Sample * Sample Read Metadata Program * for SAS/Warehouse Administrator */ length primary_repos_id $ 8; length sec_repos_id $ 8; init: /* * Create an instance of the metadata API. */ i_api=instance(loadclass (’SASHELP.METAAPI.METAAPI.CLASS’)); l_rc=0; /* * Access the SAS/Warehouse Administrator * Sample repository. */ path="!SASROOT\whouse\dwdemo\_master"; repos_type=’WHDWENV’; /* * Insert the Location information into the * metadata list with * a name of LIBRARY. 274 Read Metadata Code Sample Appendix 1 */ l_inmeta=makelist(); l_lib=makelist(); l_inmeta=insertl(l_inmeta,l_lib,-1,’LIBRARY’); /* * Use the default Libname Engine to * access a Local Path. */ l_lib=insertc(l_lib,’ ’,-1,’ENGINE’); l_path=makelist(); l_lib=insertl(l_lib,l_path,-1,’PATH’); l_opts=makelist(); l_lib=insertl(l_lib,l_opts,-1,’OPTIONS’); l_path=insertc(l_path,path,-1); /* * Set the primary repository. If a bad * return code is returned, * then we can’t continue. */ call send(i_api,’_SET_PRIMARY_REPOSITORY_’, l_rc,l_inmeta, repos_type,primary_repos_id,l_meta); l_inmeta=dellist(l_inmeta,’Y’); if l_rc = 0 then do; /* * We were able to access the primary repository * correctly. */ /* * Get the list of available secondary repositories * under this primary repository. * */ l_reps=makelist(); l_meta=setniteml(l_meta,l_reps,’REPOSITORIES’); call send(i_api,’_GET_METADATA_’,l_rc,l_meta); if l_rc = 0 then do; num_reps=listlen(l_reps); if num_reps > 0 then do; /* * If any secondary repositories, select one to set as * the active one. */ l_sec_rep=getiteml(l_reps,1); call send(i_api,’_SET_SECONDARY_REPOSITORY_’,l_rc, l_sec_rep,sec_repos_id); /* * If l_rc = 0 then sec_repos_id contains the 8 * character repository id of this repository. This * id is used as the first part of any identifiers that are used * to access metadata in this secondary repository. */ if l_rc = 0 then do; /* * Get the List of Detail Tables in the secondary Sample Metadata API Code Read Metadata Code Sample 275 * repository. */ of_type=sec_repos_id||’.’||’WHDETAIL’; l_tables=makelist(); call send(i_api,’_GET_METADATA_OBJECTS_’,l_rc, of_type,l_tables); num_tables=listlen(l_tables); if num_tables > 0 and l_rc = 0 then do; table_id=nameitem(l_tables,1); table_name=getitemc(l_tables,1); put ’Processing Table: ’ table_name; /* * Get the metadata about the Load Process that created * this table. Note that this is an example of a * selective query, for example preformat the input list with * only the properties desired. */ get_all=0; expand=0; l_table_meta=makelist(); l_table_meta=insertc(l_table_meta,table_id,-1,’ID’); l_table_meta=insertl(l_table_meta,0,-1,’PROCESS’); call send(i_api,’_GET_METADATA_’,l_rc,l_table_meta); if l_rc = 0 then do; l_process_meta=getniteml(l_table_meta,’PROCESS’); /* * It is possible that the process has not yet been * defined for this table. If this is the case, an * empty list will be returned. */ if listlen(l_process_meta) > 0 then do; /* * Get all metadata known about this process by * issuing a _GET_METADATA_ with the get_all * parameter as 1. */ get_all=1; expand=0; call send(i_api,’_GET_METADATA_’,l_rc, l_process_meta,get_all,expand); if l_rc = 0 then do; /* * Perform some processing on the returned * metadata list. */ end; /* if */ else do; msg=getnitemc(l_rc,’MSG’); 276 Read Metadata Code Sample Appendix 1 rc=getnitemn(l_rc,’RC’); put msg; put ’RC=’ rc; end; /* else */ end; /* if */ end; /* if */ else do; msg=getnitemc(l_rc,’MSG’); rc=getnitemn(l_rc,’RC’); put msg; put ’RC=’ rc; end; /* else */ /* * Delete the table metadata list and all of its * sublists. * * NOTE: Be extremely careful when using the DELLIST * with the ’Y’ option. */ l_table_meta=dellist(l_table_meta,’Y’); end; /* if */ else do; if l_rc = 0 then do; put ’No detail tables found.’; end; /* if */ else do; msg=getnitemc(l_rc,’MSG’); rc=getnitemn(l_rc,’RC’); put msg; put ’RC=’ rc; end; /* else */ end; /* else */ l_tables=dellist(l_tables); end; /* if */ else do; msg=getnitemc(l_rc,’MSG’); rc=getnitemn(l_rc,’RC’); put msg; put ’RC=’ rc; end; /* else */ end; /* if */ end; /* if */ else do; msg=getnitemc(l_rc,’MSG’); rc=getnitemn(l_rc,’RC’); put msg; put ’RC=’ rc; end; /* else */ end; /* if */ else do; . 27 2 27 3 APPENDIX 1 Sample Metadata API Code Appendix Overview 27 3 Read Metadata Code Sample 27 3 Write Metadata Code Sample 27 7 Appendix Overview This appendix. Overview This appendix contains SCL code that uses the metadata API to access SAS/Warehouse Administrator metadata. For longer examples, see the sample metadata API applications in the SAMPSIO.DWADDIN. includes the BLDPAGE program, which reads metadata and outputs it in HTML format. Read Metadata Code Sample * Sample Read Metadata Program * for SAS/Warehouse Administrator */ length primary_repos_id

Ngày đăng: 05/07/2014, 07:20