QueryResult SetQuery(OdId tOb, SetQueryArg tArg)
tOb. Moniker of repository object that is query.
tArg. Operation execution parameters.
The SetQuery operation changes the Query repository object.
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.
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.
{
"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"
}
}
}
}
{
"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: