SetQuery

Syntax

QueryResult SetQuery(OdId tOb, SetQueryArg tArg)

Parameters

tOb. Moniker of repository object that is query.

tArg. Operation execution parameters.

Description

The SetQuery operation changes the Query repository object.

Comments

The operation changes SQL query text and parameters. A query should be opened for edit. To execute the operation, in the tOb field specify moniker of opened query instance, and in the tArg.meta field specify updated metadata to be applied. The moniker can be obtained on executing the OpenQuery 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 changing SQL query in the Query object. The request contains moniker of opened object instance and a new SQL query. The response contains the fields list and the data set obtained on executing the new SQL query.

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">
<SetQuery xmlns="http://www.fsight.ru/PP.SOM.Som">
<tOb xmlns="">
  <id>S1!M!S!QUERY6</id>
  </tOb>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
  <sqlText>true</sqlText>
  </pattern>
<meta>
<sqlText>
  <value>SELECT * FROM T_SOURCE</value>
  </sqlText>
  </meta>
<metaGet>
  <obInst>true</obInst>
  <fields>true</fields>
  <rows>Get</rows>
  </metaGet>
  </tArg>
  </SetQuery>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<SetQueryResult 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!QUERY6</id>
  </id>
<meta xmlns="">
<obInst>
<obDesc ds="" isShortcut="0" isLink="0" ver="9" hf="0">
  <i>T_QUERY</i>
  <n>Query</n>
  <k>9051</k>
  <c>770</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>ISO_CODE</it>
  <it>NAME</it>
  <it>POPULATION</it>
  <it>AREA</it>
  <it>CURRENCY</it>
  </its>
  </fields>
<rows>
<its>
<r>
  <it />
  <it>Data of Federal State Statistics Service</it>
  <it />
  <it />
  <it />
  <it>1</it>
  <it>2</it>
  </r>
<r>
  <it />
  <it>Data of Ministry of Economic Development and Trade of the Russian Federation</it>
  <it />
  <it />
  <it />
  <it>2</it>
  <it>3</it>
  </r>
<r>
  <it />
  <it>Departments forecast (second version)</it>
  <it />
  <it />
  <it />
  <it>3</it>
  <it>5</it>
  </r>
<r>
  <it />
  <it>Regions data</it>
  <it />
  <it />
  <it />
  <it>4</it>
  <it>4</it>
  </r>
  </its>
  </rows>
  </meta>
  </SetQueryResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"SetQuery" :
{
"tOb" :
{
"id" : "S1!M!S!QUERY6"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"sqlText" : "true"
},
"meta" :
{
"sqlText" :
{
"value" : "SELECT * FROM T_SOURCE"
}
},
"metaGet" :
{
"obInst" : "true",
"fields" : "true",
"rows" : "Get"
}
}
}
}

JSON response:

{
"SetQueryResult" :
{
"id" :
{
"id" : "S1!M!S!QUERY6"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "9",
"@hf" : "0",
"i" : "T_QUERY",
"n" : "Query",
"k" : "9051",
"c" : "770",
"p" : "9050",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"isPermanent" : "1",
"isTemp" : "0"
},
"openArgs" : ""
},
"fields" :
{
"its" :
{
"it" :
[
"ISO_CODE",
"NAME",
"POPULATION",
"AREA",
"CURRENCY"
]
}
},
"rows" :
{
"its" :
{
"r" :
[
{
"it" :
[
"",
"Data of Federal State Statistics Service",
"",
"",
"",
"1",
"2"
]
},
{
"it" :
[
"",
"Data of Ministry of Economic Development and Trade of the Russian Federation",
"",
"",
"",
"2",
"3"
]
},
{
"it" :
[
"",
"Departments forecast (second version)",
"",
"",
"",
"3",
"5"
]
},
{
"it" :
[
"",
"Regions data",
"",
"",
"",
"4",
"4"
]
}
]
}
}
}
}
}
public static QueryResult ChangeQuery(string moniker, string newSQLText)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tSet = new SetQuery()
{
tArg = new SetQueryArg()
{
meta = new QueryMd()
{
sqlText = new QuerySqlText() { value = newSQLText }
},
pattern = new QueryMdPattern
{
sqlText = true,
},
metaGet = new QueryMdPattern
{
fields = true,
rows = ListOperation.Get
}
},
tOb = new OdId() { id = moniker }
};
//Change metadata
var tResult = somClient.SetQuery(tSet);
return tResult;
}

See also:

Working with Relational Objects of Repository