Previous Page | Next Page

Updating Metadata Objects

Example of an UpdateMetadata Request That Merges Associations

The following UpdateMetadata examples illustrate the use of the MERGE directive. MERGE is the default directive for multiple associations when the Function= attribute is omitted from an UpdateMetadata request. MERGE adds and modifies associations without overwriting existing associations.

The first example adds UniqueKeys and ForeignKeys associations to the table objects created in Adding Metadata Objects. The UpdateMetadata request consists of two main parts:

<UpdateMetadata>
   <Metadata>
      <PhysicalTable Id="A53TPPVI.A4000002">
         <UniqueKeys Function="Merge">
            <UniqueKey Id="" Name="Sales Associates in NW Region">
              <KeyedColumns Function="Merge">
                <Column ObjRef="A53TPPVI.A5000005"/>
              </KeyedColumns>
              <ForeignKeys Function="Merge">
                <ForeignKey Id="" Name="Link to Sales Associates table">
                  <Table>
                    <PhysicalTable ObjRef="A53TPPVI.A4000001" 
                                   Name="Sales offices in NW Region"/>
                  </Table>
                  <KeyedColumns Function="Merge">
                    <Column ObjRef="A53TPPVI.A5000004"/>
                  </KeyedColumns>
                </ForeignKey>
             </ForeignKeys>
           </UniqueKey>
        </UniqueKeys> 
      </PhysicalTable>
   </Metadata>
   <NS>SAS</NS>
   <!-- OMI_TRUSTED_CLIENT Flag -->
   <Flags>268435456</Flags>  
   <Options/>
</UpdateMetadata>

In the request, note the following:

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

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

<PhysicalTable Id="A53TPPVI.A4000002">
<UniqueKeys>
<UniqueKey Id="A53TPPVI.A8000001" Name="Sales Associates in NW Region">
<KeyedColumns>
<Column ObjRef="A53TPPVI.A5000005"/>
</KeyedColumns>
<ForeignKeys>
<ForeignKey Id="A53TPPVI.A9000001" Name="Link to Sales Associates table">
<Table>
<PhysicalTable ObjRef="A53TPPVI.A4000001"/>
</Table>
<KeyedColumns>
<Column ObjRef="A53TPPVI.A5000004"/>
</KeyedColumns>
<PartnerUniqueKey>
<UniqueKey ObjRef="A53TPPVI.A8000001"/>
</PartnerUniqueKey>
</ForeignKey>
</ForeignKeys>
<Table>
<PhysicalTable ObjRef="A53TPPVI.A4000002"/>
</Table>
</UniqueKey>
</UniqueKeys>
</PhysicalTable>

The request created seven associations and two new objects (UniqueKey and ForeignKey).

The following example updates the UniqueKey object created in the previous request. It modifies the Name= attribute of the key column and adds an association to a second key column.

<UpdateMetadata>
   <Metadata>
      <UniqueKey Id="A53TPPVI.A8000001">
         <KeyedColumns>
             <Column Id="A53TPPVI.A5000005" Name="EmployeeName"/>
             <Column ObjRef="A53TPPVI.A5000006"/>
          </KeyedColumns>
      </UniqueKey>
   </Metadata>
   <NS>SAS</NS>
   <!-- OMI_TRUSTED_CLIENT Flag -->
   <Flags>268435456</Flags>  
   <Options/>
</UpdateMetadata>

In the request, note the following:

Here are the results of a GetMetadata request that lists the UniqueKey object's KeyedColumns associations:

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

<UniqueKey Id="A53TPPVI.A8000001" Name="Sales Associates in NW Region">
<KeyedColumns>
<Column Id="A53TPPVI.A5000005" Name="EmployeeName" Desc="Name of employee"/>
<Column Id="A53TPPVI.A5000006" Name="Address" Desc="Home Address"/>
</KeyedColumns>
</UniqueKey>

Two Column objects are returned. Column A53TPPVI.A5000005's Name= attribute was changed from Name to EmployeeName.

Previous Page | Next Page | Top of Page