GetQuery

Syntax

QueryResult GetQuery(OdId tOb, GetQueryArg tArg)

Parameters

tOb. Moniker of repository object that is query.

tArg. Operation execution parameters.

Description

The GetQuery operation gets metadata of the Query repository object.

Comments

The operation enables the user to get 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.

Example

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.

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

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<GetQueryResult 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="8" 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>
<sqlText>
  <value>SELECT * FROM T_COUNTRY</value>
  </sqlText>
<fields>
<its>
  <it>ISO_CODE</it>
  <it>NAME</it>
  <it>POPULATION</it>
  <it>AREA</it>
  <it>CURRENCY</it>
  </its>
  </fields>
<rows>
<its>
<r>
  <it>RU</it>
  <it>Russia</it>
  <it>143666931</it>
  <it>17125187</it>
  <it>Russian ruble (RUB)</it>
  </r>
<r>
  <it>US</it>
  <it>United States of America</it>
  <it>320194478</it>
  <it>9519431</it>
  <it>United States dollar ($) (USD)</it>
  </r>
  </its>
  </rows>
  </meta>
  </GetQueryResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"GetQuery" :
{
"tOb" :
{
"id" : "S1!M!S!QUERY6"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"fields" : "true",
"rows" : "Get",
"sqlText" : "true"
}
}
}
}

JSON response:

{
"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:

Working with Relational Objects of Repository