SetTable

Syntax

TableResult SetTable(OdId tOb, SetTableArg tArg)

Parameters

tOb. Moniker of repository object that is table, external table or view.

tArg. Operation execution parameters.

Description

The SetTable operation changes table/external table/view.

Comments

The operation enables the user to change structure of table/external table/view. Table/external table/view should be opened for edit. To execute the operation, in the tOb field specify moniker of opened object instance, and in the tArg.meta field specify updated metadata to be applied. The moniker can be obtained on executing the OpenTable operation. In the tArg.pattern field specify the pattern that will be used to change metadata. If the tArg.metaGet field is defined, the operation results in the updated metadata that will be again obtained after its changing in the object. The changes are saved automatically on executing the operation.

Example

The example of adding a new index to table structure. The request contains moniker of opened table instance and updated metadata with added index parameters. The response contains the list of table fields and indexes.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SetTable xmlns="http://www.fsight.ru/PP.SOM.Som">
<tOb xmlns="">
  <id>S1!M!S!TABLE5</id>
  </tOb>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
<indexes>
  <indexes>Add</indexes>
  <indexesFields>Add</indexesFields>
  </indexes>
  </pattern>
<meta>
<indexes>
<its>
<it>
  <k>0</k>
  <id>NEW_INDEX</id>
  <n>New index</n>
  <unique>true</unique>
<indexFields>
<its>
<it>
  <k>1</k>
  <id>ISO_CODE</id>
  <n>ISO country code</n>
  <vis>true</vis>
  <dt>1</dt>
  <mandatory>true</mandatory>
  <defaultValue />
  <size>255</size>
  <precision>0</precision>
  <isCalculated>false</isCalculated>
  </it>
  </its>
  </indexFields>
  </it>
  </its>
  </indexes>
  </meta>
<metaGet>
  <obInst>true</obInst>
  <fields>Get</fields>
<indexes>
  <indexes>Get</indexes>
  </indexes>
  </metaGet>
  </tArg>
  </SetTable>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<SetTableResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xmlns="">
  <id>S1!M!S!TABLE5</id>
  </id>
<meta xmlns="">
<obInst>
<obDesc ds="" isShortcut="0" isLink="0" ver="21" hf="0">
  <i>T_COUNTRY_INFO</i>
  <n>Data by countries</n>
  <k>9053</k>
  <c>769</c>
  <p>9050</p>
  <h>0</h>
  <hasPrv>0</hasPrv>
  <ic>0</ic>
  <isPermanent>1</isPermanent>
  <isTemp>0</isTemp>
  </obDesc>
  <openArgs />
  </obInst>
<fields>
<its>
<it>
  <k>1</k>
  <id>ISO_CODE</id>
  <n>ISO country code</n>
  <vis>1</vis>
  <dt>1</dt>
  <mandatory>1</mandatory>
  <defaultValue />
  <size>255</size>
  <precision>0</precision>
  <isCalculated>0</isCalculated>
  </it>
<it>
  <k>2</k>
  <id>NAME</id>
  <n>Name</n>
  <vis>1</vis>
  <dt>1</dt>
  <mandatory>1</mandatory>
  <defaultValue />
  <size>255</size>
  <precision>0</precision>
  <isCalculated>0</isCalculated>
  </it>
<it>
  <k>3</k>
  <id>POPULATION</id>
  <n>Population</n>
  <vis>1</vis>
  <dt>3</dt>
  <mandatory>0</mandatory>
  <defaultValue />
  <size>20</size>
  <precision>2</precision>
  <isCalculated>0</isCalculated>
  </it>
<it>
  <k>4</k>
  <id>AREA</id>
  <n>Area</n>
  <vis>1</vis>
  <dt>3</dt>
  <mandatory>0</mandatory>
  <defaultValue />
  <size>20</size>
  <precision>2</precision>
  <isCalculated>0</isCalculated>
  </it>
<it>
  <k>5</k>
  <id>CURRENCY</id>
  <n>Currency</n>
  <vis>1</vis>
  <dt>1</dt>
  <mandatory>0</mandatory>
  <defaultValue />
  <size>255</size>
  <precision>0</precision>
  <isCalculated>0</isCalculated>
  </it>
  </its>
  </fields>
<indexes>
<its>
<it>
  <k>1</k>
  <id>T_COUNTRY_INDEX</id>
  <n>Index</n>
  <vis>1</vis>
  <primary>1</primary>
  <unique>1</unique>
  <allowNulls>0</allowNulls>
  <clustered>2</clustered>
<indexFields>
<its>
<it>
  <k>1</k>
  <id>ISO_CODE</id>
  <n>ISO country code</n>
  <vis>1</vis>
  <dt>1</dt>
  <mandatory>1</mandatory>
  <defaultValue />
  <size>255</size>
  <precision>0</precision>
  <isCalculated>0</isCalculated>
  </it>
<it>
  <k>2</k>
  <id>NAME</id>
  <n>Name</n>
  <vis>1</vis>
  <dt>1</dt>
  <mandatory>1</mandatory>
  <defaultValue />
  <size>255</size>
  <precision>0</precision>
  <isCalculated>0</isCalculated>
  </it>
  </its>
  </indexFields>
  <expression />
  </it>
<it>
  <k>2</k>
  <id>NEW_INDEX</id>
  <n>New index</n>
  <vis>1</vis>
  <primary>0</primary>
  <unique>1</unique>
  <allowNulls>0</allowNulls>
  <clustered>2</clustered>
<indexFields>
<its>
<it>
  <k>1</k>
  <id>ISO_CODE</id>
  <n>ISO country code</n>
  <vis>1</vis>
  <dt>1</dt>
  <mandatory>1</mandatory>
  <defaultValue />
  <size>255</size>
  <precision>0</precision>
  <isCalculated>0</isCalculated>
  </it>
  </its>
  </indexFields>
  <expression />
  </it>
  </its>
  </indexes>
  </meta>
  </SetTableResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"SetTable" :
{
"tOb" :
{
"id" : "S1!M!S!TABLE5"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"indexes" :
{
"indexes" : "Add",
"indexesFields" : "Add"
}
},
"meta" :
{
"indexes" :
{
"its" :
{
"it" :
[
{
"k" : "0",
"id" : "NEW_INDEX",
"n" : "New index",
"unique" : "true",
"indexFields" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"id" : "ISO_CODE",
"n" : "ISO country code",
"vis" : "true",
"dt" : "1",
"mandatory" : "true",
"defaultValue" : "",
"size" : "255",
"precision" : "0",
"isCalculated" : "false"
}
]
}
}
}
]
}
}
},
"metaGet" :
{
"obInst" : "true",
"fields" : "Get",
"indexes" :
{
"indexes" : "Get"
}
}
}
}
}

JSON response:

{
"SetTableResult" :
{
"id" :
{
"id" : "S1!M!S!TABLE5"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "21",
"@hf" : "0",
"i" : "T_COUNTRY_INFO",
"n" : "Data by countries",
"k" : "9053",
"c" : "769",
"p" : "9050",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"isPermanent" : "1",
"isTemp" : "0"
},
"openArgs" : ""
},
"fields" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"id" : "ISO_CODE",
"n" : "ISO country code",
"vis" : "1",
"dt" : "1",
"mandatory" : "1",
"defaultValue" : "",
"size" : "255",
"precision" : "0",
"isCalculated" : "0"
},
{
"k" : "2",
"id" : "NAME",
"n" : "Name",
"vis" : "1",
"dt" : "1",
"mandatory" : "1",
"defaultValue" : "",
"size" : "255",
"precision" : "0",
"isCalculated" : "0"
},
{
"k" : "3",
"id" : "POPULATION",
"n" : "Population",
"vis" : "1",
"dt" : "3",
"mandatory" : "0",
"defaultValue" : "",
"size" : "20",
"precision" : "2",
"isCalculated" : "0"
},
{
"k" : "4",
"id" : "AREA",
"n" : "Area",
"vis" : "1",
"dt" : "3",
"mandatory" : "0",
"defaultValue" : "",
"size" : "20",
"precision" : "2",
"isCalculated" : "0"
},
{
"k" : "5",
"id" : "CURRENCY",
"n" : "Currency",
"vis" : "1",
"dt" : "1",
"mandatory" : "0",
"defaultValue" : "",
"size" : "255",
"precision" : "0",
"isCalculated" : "0"
}
]
}
},
"indexes" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"id" : "T_COUNTRY_INDEX",
"n" : "Index",
"vis" : "1",
"primary" : "1",
"unique" : "1",
"allowNulls" : "0",
"clustered" : "2",
"indexFields" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"id" : "ISO_CODE",
"n" : "ISO country code",
"vis" : "1",
"dt" : "1",
"mandatory" : "1",
"defaultValue" : "",
"size" : "255",
"precision" : "0",
"isCalculated" : "0"
},
{
"k" : "2",
"id" : "NAME",
"n" : "Name",
"vis" : "1",
"dt" : "1",
"mandatory" : "1",
"defaultValue" : "",
"size" : "255",
"precision" : "0",
"isCalculated" : "0"
}
]
}
},
"expression" : ""
},
{
"k" : "2",
"id" : "NEW_INDEX",
"n" : "New index",
"vis" : "1",
"primary" : "0",
"unique" : "1",
"allowNulls" : "0",
"clustered" : "2",
"indexFields" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"id" : "ISO_CODE",
"n" : "ISO country code",
"vis" : "1",
"dt" : "1",
"mandatory" : "1",
"defaultValue" : "",
"size" : "255",
"precision" : "0",
"isCalculated" : "0"
}
]
}
},
"expression" : ""
}
]
}
}
}
}
}
public static TableResult ChangeTable(string moniker, TableField field, ListOperation operation)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tSet = new SetTable()
{
tArg = new SetTableArg()
{
meta = new TableMd()
{
indexes = new TableIndexes()
{
its = new TableIndex[]
{
new TableIndex()
{
id = "NEW_INDEX",
n = "New index",
indexFields = new TableFields()
{
its = new TableField[]
{
field
}
},
unique = true
}
}
}
},
pattern = new TableMdPattern()
{
indexes = new TableIndexesPattern()
{
indexes = operation,
indexesFields = operation
}
},
metaGet = new TableMdPattern()
{
indexes = new TableIndexesPattern()
{
indexes = ListOperation.Get
},
fields = ListOperation.Get
}
},
tOb = new OdId() { id = moniker }
};
//Change metadata
var tResult = somClient.SetTable(tSet);
return tResult;
}

See also:

Working with Relational Objects of Repository