QueryResult GetQuery(OdId tOb, GetQueryArg tArg)
tOb. Moniker of repository object that is query.
tArg. Operation execution parameters.
The GetQuery operation gets metadata of the Query repository object.
The operation gets information about SQL query text and parameters, and also about the data set to be obtained on query execution. To execute the operation, in the tOb field specify moniker of opened query instance, and in the tArg field specify parameters for getting metadata. The moniker can be obtained on executing the OpenQuery operation. The operation results in the requested metadata.
The example of getting information about SQL query saved in the Query object, and also about the data set to be obtained on executing this SQL query. The request contains moniker of opened instance of the Query object and the pattern that determines whether it is necessary to get this information. The response contains requested information.
{
"GetQuery" :
{
"tOb" :
{
"id" : "S1!M!S!QUERY6"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"fields" : "true",
"rows" : "Get",
"sqlText" : "true"
}
}
}
}
{
"GetQueryResult" :
{
"id" :
{
"id" : "S1!M!S!QUERY6"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "8",
"@hf" : "0",
"i" : "T_QUERY",
"n" : "Query",
"k" : "9051",
"c" : "770",
"p" : "9050",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"isPermanent" : "1",
"isTemp" : "0"
},
"openArgs" : ""
},
"sqlText" :
{
"value" : "SELECT * FROM T_COUNTRY"
},
"fields" :
{
"its" :
{
"it" :
[
"ISO_CODE",
"NAME",
"POPULATION",
"AREA",
"CURRENCY"
]
}
},
"rows" :
{
"its" :
{
"r" :
[
{
"it" :
[
"RU",
"Russia",
"143666931",
"17125187",
"Russian ruble (RUB)"
]
},
{
"it" :
[
"US",
"United States of America",
"320194478",
"9519431",
"United States dollar ($) (USD)"
]
}
]
}
}
}
}
}
public static QueryResult GetQueryMetadata(string moniker)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tGet = new GetQuery()
{
tArg = new GetQueryArg()
{
pattern = new QueryMdPattern
{
sqlText = true,
fields = true,
rows = ListOperation.Get
}
},
tOb = new OdId() { id = moniker }
};
//Get metadata
var tResult = somClient.GetQuery(tGet);
return tResult;
}
See also: