Previous Page | Next Page

Adding Metadata Objects

Example of an AddMetadata Request That Creates Multiple, Related Metadata Objects

The following AddMetadata request creates a table object, column objects, and an association to the previously defined SASLibrary object in a single method call. The SAS Metadata Model supports several metadata types for describing tables. In this example, the PhysicalTable metadata type is used to represent a table that is materialized in a file system. A PhysicalTable object is associated to a Column object with a Columns association. A PhysicalTable object is associated to a SASLibrary object with a TablePackages association.

<AddMetadata>
 <Metadata>
   <PhysicalTable Name="Sales Offices" Desc="Sales offices in NW region" 
     PublicType="Table">
     <TablePackages>
       <SASLibrary ObjRef="A53TPPVI.A1000001"/>
     </TablePackages>
     <Columns>
        <Column
           Name="City"
           Desc="City of Sales Office"
           ColumnName="City"
           SASColumnName="City"
           ColumnType="12"
           SASColumnType="C"
           ColumnLength="32"
           SASColumnLength="32"
           SASFormat="$Char32."
           SASInformat="$32."
          PublicType="Column"/>
        <Column
           Name="Address"
           Desc="Street Address of Sales Office"
           ColumnName="Address"
           SASColumnName="Street_Address"
           ColumnType="12"
           SASColumnType="C"
           ColumnLength="32"
           SASColumnLength="32"
           SASFormat="$Char32."
           SASInformat="$32."
          PublicType="Column"/>
        <Column
           Name="Manager"
           Desc="Name of Operations Manager"
           ColumnName="Manager"
           SASColumnName="Manager"
           ColumnType="12"
           SASColumnType="C"
           ColumnLength="32"
           SASColumnLength="32"
           SASFormat="$Char32."
           SASInformat="$32."
          PublicType="Column"/>
        <Column
          Name="Employees"
          Desc="Number of employees"
          ColumnName="Employees"
          SASColumnName="Employees"
          ColumnType="6"
          SASColumnType="N"
          ColumnLength="3"
          SASColumnLength="3"
          SASFormat="3.2"
          SASInformat="3.2"
          PublicType="Column"/>
        </Columns>
    </PhysicalTable>
 </Metadata>
 <Reposid>A0000001.A53TPPVI</Reposid>
 <NS>SAS</NS>
 <Flags>268435456</Flags>
 <Options/>
</AddMetadata>

In the request, the <REPOSID>, <NS>, and <FLAGS> elements contain the same values as in Example of an AddMetadata Request That Creates an Application Metadata Object. In the <METADATA> property string, note the following:

Here is an example of the output returned by the SAS Metadata Server:

<!-- Using the ADDMETADATA method. -->

<PhysicalTable Name="Sales Offices" Desc="Sales offices in NW region" 
 Id="A53TPPVI.A4000001">
 <TablePackages>
  <SASLibrary ObjRef="A53TPPVI.A1000001"/>
 </TablePackages>
 <Columns>
  <Column Name="City" Desc="City of Sales Office" ColumnName="City" 
    SASColumnName="City"  ColumnType="12" SASColumnType="C" ColumnLength="32" 
    SASColumnLength="32" SASFormat="$Char32." SASInformat="$32." 
    PublicType="Column" Id="A53TPPVI.A5000001">
    <Table>
     <PhysicalTable ObjRef="A53TPPVI.A4000001"/>
    </Table>
  </Column>
  <Column Name="Address" Desc="Street Address of Sales Office" 
    ColumnName="Address" SASColumnName="Street_Address" ColumnType="12" 
    SASColumnType="C" ColumnLength="32" SASColumnLength="32" SASFormat="$Char32." 
    SASInformat="$32." PublicType="Column"  Id="A53TPPVI.A5000002">
    <Table>
     <PhysicalTable ObjRef="A53TPPVI.A4000001"/>
    </Table>
  </Column>
  <Column Name="Manager" Desc="Name of Operations Manager" ColumnName="Manager" 
    SASColumnName="Manager" ColumnType="12" SASColumnType="C" ColumnLength="32" 
    SASColumnLength="32" SASFormat="$Char32." SASInformat="$32." 
    PublicType="Column" Id="A53TPPVI.A5000003">
    <Table>
     <PhysicalTable ObjRef="A53TPPVI.A4000001"/>
    </Table>
  </Column>
  <Column Name="Employees" Desc="Number of employees" ColumnName="Employees" 
    SASColumnName="Employees" ColumnType="6" SASColumnType="N" ColumnLength="3" 
    SASColumnLength="3" SASFormat="3.2" SASInformat="3.2" PublicType="Column" 
    Id="A53TPPVI.A5000004">
    <Table>
     <PhysicalTable ObjRef="A53TPPVI.A4000001"/>
    </Table>
  </Column>
</Columns>
</PhysicalTable>

The output string mirrors the input string, with the exception that a two-part metadata object identifier is assigned to each new metadata object.

Previous Page | Next Page | Top of Page