![]() |
![]() |
Metadata API Class |
Category: | Write Methods |
Syntax | |
Parameters | |
Details | |
Using _UPDATE_METADATA_ | |
Examples | |
Example 1: Add New Columns to the Selected Table | |
Example 2: Add Extended Attributes | |
See Also |
Syntax |
CALL SEND(i_api, '_UPDATE_METADATA_', l_rc, l_meta); |
Parameter | Type | Description |
---|---|---|
i_api | Class | specifies the passed instance of METAAPI.CLASS. See Using the Metadata API Class. |
l_rc | N | specifies the return codes for the method. A nonzero code indicates failure and means that l_rc is an error list identifier. For the error list format, see Error Codes. |
l_metadata | L | specifies the passed metadata property list for the object that is to be updated. For the general format of this list, see Metadata Property List. |
Details |
specifies the passed metadata property list for the object that is to be updated. The ID value in l_meta should be reposid.typeid.instanceid.
To add properties to an existing object, the ID value in l_meta should be reposid.typeid.instanceid.
Using _UPDATE_METADATA_ |
Keep the following in mind when you use the _UPDATE_METADATA_ method:
Always check the return code of a write method call. A nonzero return code indicates that a failure has occurred while trying to write to the metadata. If a nonzero return code is returned, none of the changes that are indicated by this method call will be made.
The_UPDATE_METADATA_ method supports indirect adds of dependent types. For example, a physical storage (WHSASSTR) will be created and added to a data table (WHDATTBL) when it is passed as the physical storage property in the l_meta list for the update of WHDATTBL. As another example, a new column (WHCOLDAT) will be created and added to a data table (WHDATTBL) when it is passed in the Columns property in the l_meta list for the update of WHDATTBL.
The_UPDATE_METADATA_ method does not support cascading updates. You can update properties of an existing instance of a type only by using an _UPDATE_METADATA_ call directly on that instance.
When you pass a list for a property of an object through the _UPDATE_METADATA_ method, and the existing property list is empty for the object -- or if the list can be a list of objects, UPDATE will add (for independent types) or create and add (for dependent types) the object to the existing list.
For example, given an existing job (WHJOB) with several output tables associated with it, an existing detail table (WHDETAIL) will also be associated with that job when it is passed in the output tables property in the l_meta list for the update of WHJOB. As another example, given an existing OLAP table (WHOLPTBL) with several extended attributes (WHEXTATR) associated with it, a new extended attribute will be created and associated with when it is passed in the extended attributes property in the l_meta list for the update of WHOLPTBL.
When you pass a list for a property through the _UPDATE_METADATA_ method, and the property can only be a list with a single object, UPDATE will replace the existing object with another existing object that is being passed in l_meta.
For example, given that an OLAP table has an existing library (WHLIBRY) associated with it, a call to the _UPDATE_METADATA_ method for the OLAP table (WHOPLTBL) will replace the library with another existing library when it is passed in the l_meta list for the update of WHOLPTBL.
Examples |
l_meta=makelist(); /* * object_id is the ID of an existing Data Table object. */ l_meta=insertc(l_meta,object_id,-1,'ID'); /* * Define a column. The COLUMNS property * contains a sublist per column. */ l_cols=makelist(); l_col=makelist(); l_cols=insertl(l_cols,l_col,-1); l_meta=insertl(l_meta,l_cols,-1,'COLUMNS'); col_id=repos_id||'.'||'WHCOLUMN'; l_col=insertc(l_col,col_id,-1,'ID'); l_col=insertc(l_col,'SaleDate',-1,'NAME'); l_col=insertc(l_col,'Date of Sale',-1,'DESC'); l_col=insertc(l_col,'N',-1,'TYPE'); l_col=insertn(l_col,8,-1,'LENGTH'); l_col=insertc(l_col,'DATE7.',-1,'FORMAT'); l_col=insertc(l_col,'DATE7.',-1,'INFORMAT'); /* * Update any additional properties. * : * : */ /* * Update the table. */ call send(i_api,'_UPDATE_METADATA_',l_rc,l_meta); if l_rc = 0 then do; put 'Table Updated successfully'; end; /* if */ else do; msg=getnitemc(l_rc,'MSG',1,1,'ERROR: _UPDATE_METADATA_ FAILED'); put msg; list_rc=dellist(l_rc); end; /* else */ l_meta=dellist(l_meta,'Y');
/* * object_id is the ID of an existing Data Table object. */ l_meta=makelist(); l_meta=insertc(l_meta,object_id,-1,'ID'); /* * Attributes */ l_attrs=makelist(); l_attr=makelist(); l_attr=insertc(l_attr,'Loader',1,'NAME'); l_attr=insertc(l_attr,'Oracle',-1,'VALUE'); l_attr=insertc(l_attr,'Name of loader used',-1,'DESC'); l_attrs=insertl(l_attrs,l_attr,-1); l_meta=insertl(l_meta,l_attrs,-1,'EXTENDED ATTRIBUTES'); call send(i_api, '_UPDATE_METADATA_',l_rc,l_meta);
See Also |
_ADD_METADATA_, _DELETE_METADATA_
![]() |
![]() |
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.