Getting Information about SQL Object Structure

Below is the example of using the GetDbCommand operation to get information about SQL query text and field structure of the data set returned on executing the request. The request contains the opened SQL object instance moniker and the pattern that determines whether 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">
<GetDbCommand xmlns="http://www.fsight.ru/PP.SOM.Som">
<tDbCommand xmlns="">
  <id>S1!M!S!M1</id>
  </tDbCommand>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
  <text>true</text>
  <fields>Get</fields>
  </pattern>
  </tArg>
  </GetDbCommand>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<GetDbCommandResult 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!M1</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>
  </obInst>
  <dirty>0</dirty>
  <type>Query</type>
<text>
<its>
<it>
  <driverID>ORCL8</driverID>
  <driverName>Oracle</driverName>
  <sqlText />
  </it>
<it>
  <driverID>MSSQL</driverID>
  <driverName>Microsoft SQL Server 6.x\7.x\2000</driverName>
  <sqlText />
  </it>
<it>
  <driverID>MSSQL2005</driverID>
  <driverName>Microsoft SQL Server 2005</driverName>
  <sqlText />
  </it>
<it>
  <driverID>MSSQL2008</driverID>
  <driverName>Microsoft SQL Server 2008</driverName>
  <sqlText />
  </it>
<it>
  <driverID>MSSQL2012</driverID>
  <driverName>Microsoft SQL Server 2012\2014\2016</driverName>
  <sqlText />
  </it>
<it>
  <driverID>MSSQL2012ODBC</driverID>
  <driverName>Microsoft SQL Server (ODBC)</driverName>
  <sqlText />
  </it>
<it>
  <driverID>ODBC</driverID>
  <driverName>Generic ODBC</driverName>
  <sqlText />
  </it>
<it>
  <driverID>OLEDB(ODBC HIVE)</driverID>
  <driverName>OLE DB(ODBC HIVE)</driverName>
  <sqlText />
  </it>
<it>
  <driverID>OLEDB(DB2)</driverID>
  <driverName>OLE DB(DB2)</driverName>
  <sqlText />
  </it>
<it>
  <driverID>OLEDB(ODBC)</driverID>
  <driverName>OLE DB(ODBC)</driverName>
  <sqlText />
  </it>
<it>
  <driverID>OLEDB(VISTADB)</driverID>
  <driverName>OLE DB(VISTADB)</driverName>
  <sqlText />
  </it>
<it>
  <driverID>OLEDB</driverID>
  <driverName>OLE DB</driverName>
  <sqlText />
  </it>
<it>
  <driverID>DB2</driverID>
  <driverName>DB2</driverName>
  <sqlText />
  </it>
<it>
  <driverID>TRDT</driverID>
  <driverName>Teradata</driverName>
  <sqlText />
  </it>
<it>
  <driverID>POSTGRES(NO_LO)</driverID>
  <driverName>Greenplum/Pivotal HD Hawq</driverName>
  <sqlText />
  </it>
<it>
  <driverID>POSTGRES</driverID>
  <driverName>PostgreSQL</driverName>
  <sqlText />
  </it>
<it>
  <driverID>SQLITE</driverID>
  <driverName>SQLite</driverName>
  <sqlText />
  </it>
<it>
  <driverID>WSF</driverID>
  <driverName>WEB Service</driverName>
  <sqlText />
  </it>
<it>
  <driverID>VERTICA</driverID>
  <driverName>Vertica</driverName>
  <sqlText />
  </it>
  </its>
  <sqlText>SELECT * FROM T_COUNTRY</sqlText>
  </text>
<fields>
<its>
<it>
  <k>5</k>
  <id>ISO_CODE</id>
  <n>ISO_CODE</n>
  <vis>1</vis>
  <dt>1</dt>
  <size>255</size>
  <precision>0</precision>
  </it>
<it>
  <k>6</k>
  <id>NAME</id>
  <n>NAME</n>
  <vis>1</vis>
  <dt>1</dt>
  <size>255</size>
  <precision>0</precision>
  </it>
<it>
  <k>7</k>
  <id>POPULATION</id>
  <n>POPULATION</n>
  <vis>1</vis>
  <dt>3</dt>
  <size>22</size>
  <precision>2</precision>
  </it>
<it>
  <k>8</k>
  <id>AREA</id>
  <n>AREA</n>
  <vis>1</vis>
  <dt>3</dt>
  <size>22</size>
  <precision>2</precision>
  </it>
<it>
  <k>9</k>
  <id>CURRENCY</id>
  <n>CURRENCY</n>
  <vis>1</vis>
  <dt>1</dt>
  <size>255</size>
  <precision>0</precision>
  </it>
  </its>
  </fields>
  </meta>
  </GetDbCommandResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"GetDbCommand" :
{
"tDbCommand" :
{
"id" : "S1!M!S!M1"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"text" : "true",
"fields" : "Get"
}
}
}
}

JSON response:

{
"GetDbCommandResult" :
{
"id" :
{
"id" : "S1!M!S!M1"
},
"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"
}
},
"dirty" : "0",
"type" : "Query",
"text" :
{
"its" :
{
"it" :
[
{
"driverID" : "ORCL8",
"driverName" : "Oracle",
"sqlText" : ""
},
{
"driverID" : "MSSQL",
"driverName" : "Microsoft SQL Server 6.x\7.x\2000",
"sqlText" : ""
},
{
"driverID" : "MSSQL2005",
"driverName" : "Microsoft SQL Server 2005",
"sqlText" : ""
},
{
"driverID" : "MSSQL2008",
"driverName" : "Microsoft SQL Server 2008",
"sqlText" : ""
},
{
"driverID" : "MSSQL2012",
"driverName" : "Microsoft SQL Server 2012\2014\2016",
"sqlText" : ""
},
{
"driverID" : "MSSQL2012ODBC",
"driverName" : "Microsoft SQL Server (ODBC)",
"sqlText" : ""
},
{
"driverID" : "ODBC",
"driverName" : "Generic ODBC",
"sqlText" : ""
},
{
"driverID" : "OLEDB(ODBC HIVE)",
"driverName" : "OLE DB(ODBC HIVE)",
"sqlText" : ""
},
{
"driverID" : "OLEDB(DB2)",
"driverName" : "OLE DB(DB2)",
"sqlText" : ""
},
{
"driverID" : "OLEDB(ODBC)",
"driverName" : "OLE DB(ODBC)",
"sqlText" : ""
},
{
"driverID" : "OLEDB(VISTADB)",
"driverName" : "OLE DB(VISTADB)",
"sqlText" : ""
},
{
"driverID" : "OLEDB",
"driverName" : "OLE DB",
"sqlText" : ""
},
{
"driverID" : "DB2",
"driverName" : "DB2",
"sqlText" : ""
},
{
"driverID" : "TRDT",
"driverName" : "Teradata",
"sqlText" : ""
},
{
"driverID" : "POSTGRES(NO_LO)",
"driverName" : "Greenplum\/Pivotal HD Hawq",
"sqlText" : ""
},
{
"driverID" : "POSTGRES",
"driverName" : "PostgreSQL",
"sqlText" : ""
},
{
"driverID" : "SQLITE",
"driverName" : "SQLite",
"sqlText" : ""
},
{
"driverID" : "WSF",
"driverName" : "WEB Service",
"sqlText" : ""
},
{
"driverID" : "VERTICA",
"driverName" : "Vertica",
"sqlText" : ""
}
]
},
"sqlText" : "SELECT * FROM T_COUNTRY"
},
"fields" :
{
"its" :
{
"it" :
[
{
"k" : "5",
"id" : "ISO_CODE",
"n" : "ISO_CODE",
"vis" : "1",
"dt" : "1",
"size" : "255",
"precision" : "0"
},
{
"k" : "6",
"id" : "NAME",
"n" : "NAME",
"vis" : "1",
"dt" : "1",
"size" : "255",
"precision" : "0"
},
{
"k" : "7",
"id" : "POPULATION",
"n" : "POPULATION",
"vis" : "1",
"dt" : "3",
"size" : "22",
"precision" : "2"
},
{
"k" : "8",
"id" : "AREA",
"n" : "AREA",
"vis" : "1",
"dt" : "3",
"size" : "22",
"precision" : "2"
},
{
"k" : "9",
"id" : "CURRENCY",
"n" : "CURRENCY",
"vis" : "1",
"dt" : "1",
"size" : "255",
"precision" : "0"
}
]
}
}
}
}
}
public static GetDbCommandResult GetSQLObjectParameters(DbCommandId moniker)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tGet = new GetDbCommand()
{
tArg = new GetDbCommandArg()
{
pattern = new DbCommandMdPattern()
{
fields = ListOperation.Get,
text = true
}
},
tDbCommand = moniker
};
//Get parameters
var tResult = somClient.GetDbCommand(tGet);
return tResult;
}

See also:

GetDbCommand