Using value tables


In this topic


About using value tables

A value table is a flexible object that can be used as input for a multivalue parameter. The previous examples of multivalue parameter values focus on the text value of the parameter, which can become difficult to use when there are numerous values with complex paths.
The value table is used to organize the values into a table, so values can be added or removed, eliminating the complexity of parsing a multivalue text string. The table can be considered a virtual matrix of values that is not persisted as an actual table because it is a device for managing many values in a program. 
A value table can contain many columns. Each column corresponds to a value in the defined parameter. Union, for example, requires the path to a dataset or a layer name, and an optional priority rank for each input entry. A value table for Union requires two columns—one for the data and one for the priority rank.

Creating and populating a value table

The following code example shows how to create and populate a value table for Union. In this example, add a reference to the com.esri.arcgis.geoprocessing package to have access to value table object. Also, add a reference to the com.esri.arcgis.geodatabase package to access the data type and value objects. 
AddRow's row argument is space-delimited. Any value used in the row argument that contains spaces must be enclosed in quotations. In the following code example, a value table with two columns has a feature class and an index value added, for example, vt.addRow("'c:/temp/land use.shp' 2").
[Java]
// List all feature classes in the workspace.
gp.setEnvironmentValue("workspace", multiWorkspace);
IGpEnumList polygonFCs = gp.listFeatureClasses("", "polygon", "");

//Make the value table.
GPValueTable gpValueTable = new GPValueTable();
String polygon = polygonFCs.next();
String row = null;
while (!"" .equals(polygon)){
    if ("center" .equals(polygon)){
        row = polygon + " 1";
    }
    else{
        row = polygon + " 2";
    }
    gpValueTable.addRow(row);
    polygon = polygonFCs.next();
}

Union union = new Union(gpValueTable, outputWorkspace + "/unionedValueTable.shp");
gp.execute(union, null);
A value table can be populated with a multivalue string that has been passed to a script as an argument, making it easy to extract each record. See following code example:
[Java]
PValueTable valueTable = new GPValueTable();
// Where input features are a multivalue of input feature classes.
valueTable.loadFromString(inputfeatures);
);