Ниже приведен пример использования операции GetDbCommand для получения информации о тексте SQL-запроса и структуре полей набора данных, который возвращается при выполнении запроса. В запросе передается моникёр открытого экземпляра SQL-объекта и шаблон, указывающий необходимость получить данную информацию. В ответе приходит запрошенная информация.
{
"GetDbCommand" :
{
"tDbCommand" :
{
"id" : "KBCFEJFKABODGOAEODNPLELCGJNJEMEEKKAKMINPLIABGDLF!M!S!MKMLJCMFKABODGOAELEAAIAKKFADKILKEJLMIMPHCMKJAKDKO"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"parsOwnDefVals" : "true",
"text" : "true",
"fields" : "Get"
}
}
}
}
{
"GetDbCommandResult" :
{
"id" :
{
"id" : "KBCFEJFKABODGOAEODNPLELCGJNJEMEEKKAKMINPLIABGDLF!M!S!MKMLJCMFKABODGOAELEAAIAKKFADKILKEJLMIMPHCMKJAKDKO"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "14",
"@hf" : "0",
"i" : "T_QUERY",
"n" : "Query",
"k" : "9051",
"c" : "770",
"p" : "9050",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "0",
"type" : "Query",
"text" :
{
"its" :
{
"it" :
[
{
"driverID" : "ORCL8",
"driverName" : "Oracle",
"sqlText" : ""
},
{
"driverID" : "MSSQL2012",
"driverName" : "Microsoft SQL Server",
"sqlText" : "SELECT * FROM T_COUNTRY"
},
{
"driverID" : "MSSQL2012ODBC",
"driverName" : "Microsoft SQL Server (ODBC)",
"sqlText" : "SELECT * FROM T_COUNTRY"
},
{
"driverID" : "ODBC(CLICKHOUSE)",
"driverName" : "ClickHouse (ODBC)",
"sqlText" : ""
},
{
"driverID" : "ODBC",
"driverName" : "Generic ODBC",
"sqlText" : ""
},
{
"driverID" : "OLEDB(ODBC HIVE)",
"driverName" : "OLE DB(ODBC HIVE)",
"sqlText" : ""
},
{
"driverID" : "OLEDB(ODBC)",
"driverName" : "OLE DB(ODBC)",
"sqlText" : ""
},
{
"driverID" : "OLEDB",
"driverName" : "OLE DB",
"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" : ""
}
]
},
"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(); // Прокси-объект для выполнения операций
// Параметры выполнения операции
var tGet = new GetDbCommand()
{
tArg = new GetDbCommandArg()
{
pattern = new DbCommandMdPattern()
{
fields = ListOperation.Get,
text = true
}
},
tDbCommand = moniker
};
// Получение параметров
var tResult = somClient.GetDbCommand(tGet);
return tResult;
}
См. также: