We are using proc metadata (open metadata interface) to update some metadata from XML. Using updatemetadata method, how can we achieve the following:
We are using version 9.3.
Thanks in advance!
We found a solution: It has to be done in two steps.
In the first step the new column has to be added. Depending on the function you use, it will be either the first or the last column in the table metadata.
In the second step you have to use the function="replace" option with updatemetadata, where the columns are in the desired order.
Example:
In the first updatemetadata block the field TEST_PCT is added to the HBR.TEST_7 table. Because it is added with function="replace", it will be the first column of the table and the old columns will be after that.
So a second updatemetadata block is needed with the proper column order, and because at this point all columns are already existing, it will reorder them properly.
<Multiple_Requests>
<UpdateMetadata>
<Metadata>
<PhysicalTable id="A52YJRW0.B30005KO" name="HBR.TEST_7" MemberType="DATA" PublicType="Table" desc="Test_1_Notes á, é, í, ó, ö, ő, ü, ű" sastablename="TEST_7" UsageVersion="1000000">
<Columns function="replace">
<Column objref="A52YJRW0.B80008J0">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J1">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J2">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J3">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column id="$o601" name="TEST_PCT" desc=" " isnullable="1" PublicType="Column" sascolumnlength="8" sascolumnname="TEST_PCT" SASColumnType="N" SASFormat="COMMAX22.2" SASInformat="COMMAX22.2" UsageVersion="1000000">
<Notes>
<TextStore Name="PrivateNote" storedtext=" " TextRole="Note" UsageVersion="0"/>
</Notes>
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J5">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J6">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J7">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J8">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J9">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
</Columns>
</PhysicalTable>
</Metadata>
<Reposid>A0000001.A52YJRW0</Reposid>
<Type>PhysicalTable</Type>
<Objects/>
<NS>SAS</NS>
<Flags>268435456</Flags>
</UpdateMetadata>
<UpdateMetadata>
<Metadata>
<PhysicalTable id="A52YJRW0.B30005KO" name="HBR.TEST_7" UsageVersion="1000000">
<Columns function="replace">
<Column objref="A52YJRW0.B80008J0">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J1">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J2">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J3">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="$o601">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J5">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J6">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J7">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J8">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
<Column objref="A52YJRW0.B80008J9">
<Table>
<PhysicalTable objref="A52YJRW0.B30005KO"/>
</Table>
</Column>
</Columns>
</PhysicalTable>
</Metadata>
<Reposid>A0000001.A52YJRW0</Reposid>
<Type>PhysicalTable</Type>
<Objects/>
<NS>SAS</NS>
<Flags>268435456</Flags>
</UpdateMetadata>