Below is the example of using the SetDbCommand command to change request text and set DBMS command parameters. The request contains moniker of opened DBMS command instance, refreshed metadata and the pattern that determines whether to change request and parameters. The response contains refreshed information about DBMS command metadata. To save applied changes after the SetDbCommand operation also execute the SaveObject or SaveObjectAs operation.
{ "SetDbCommand" : { "tDbCommand" : { "id" : "S2!M!S!M2"
}, "tArg" : { "pattern" : { "obInst" : "true", "text" : "true", "openArgs" : "true" }, "meta" :
{ "type" : "Command", "text" : { "sqlText" : "Insert Into T_COUNTRY (ISO_CODE, NAME) values (:ISO_CODE, :NAME)" }, "openArgs" : { "args" : {
"it" : [ { "k" : "4294967295", "id" : "ISO_CODE", "n" : "ISO_CODE", "vis" : "true", "value" : "CA", "dt" : "1" },
{ "k" : "4294967295", "id" : "NAME", "n" : "NAME", "vis" : "true", "value" : "Canada", "dt" : "1" } ] }
} }, "metaGet" : { "obInst" : "true", "text" : "true", "openArgs" : "true" } } } }
{ "SetDbCommandResult" : { "id" : {
"id" : "S2!M!S!M2" }, "meta" : { "obInst" : { "obDesc" : { "@fullUrl" : "\/", "@isShortcut" : "0",
"@isLink" : "0", "i" : "OBJ9054", "n" : "DBMS command", "k" : "9054", "c" : "3841", "p" : "9050", "h" : "0" } }, "dirty" : "1",
"type" : "Command", "text" : { "its" : { "it" : [ { "driverID" : "ORCL8", "driverName" : "Oracle 9.x\10.x\11.x",
"sqlText" : "" }, { "driverID" : "MSSQL2008", "driverName" : "Microsoft SQL Server 2008", "sqlText" : "" }, { "driverID" : "MSSQL2012", "driverName" : "Microsoft SQL Server 2012",
"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" : "PostgreSQL without lo type support"
"sqlText" : "" }, { "driverID" : "POSTGRES", "driverName" : "PostgreSQL", "sqlText" : "" }, { "driverID" : "SQLITE", "driverName" : "SQLite",
"sqlText" : "" }, { "driverID" : "WSF", "driverName" : "Web Service Dal", "sqlText" : "" } ] }, "sqlText" : "Insert Into T_COUNTRY (ISO_CODE, NAME) values (:ISO_CODE, :NAME)"
}, "openArgs" : { "args" : { "it" : [ { "k" : "1", "id" : "ISO_CODE",
"n" : "ISO_CODE", "vis" : "1", "value" : "CA", "dt" : "1", "binding" : "UI="EditBox"" }, { "k" : "2", "id" : "NAME", "n" : "NAME",
"vis" : "1", "value" : "Canada", "dt" : "1", "binding" : "UI="EditBox"" } ] } } } } }
public static SetDbCommandResult ChangeSQLObjectParameters(DbCommandId moniker) { var somClient = new SomPortTypeClient(); //Proxy object for operation execution //Operation execution parameters var tSet = new SetDbCommand() { tArg = new SetDbCommandArg() { pattern = new DbCommandMdPattern() { text = true, openArgs = true }, meta = new DbCommandMd() { type = DbCommandType.Command, text = new DbCommandText() { sqlText = "Insert Into T_COUNTRY (ISO_CODE, NAME) values (:ISO_CODE, :NAME)" }, openArgs = new OdOpenArgs { args = new OdArg[] { new OdArg { k = uint.MaxValue, id = "ISO_CODE", n = "ISO_CODE", dt = 1, //DbDataType.String vis = true, value = "CA" }, new OdArg { k = uint.MaxValue, id = "NAME", n = "NAME", dt = 1, //DbDataType.String vis = true, value = "Canada" } } } }, metaGet = new DbCommandMdPattern() { text = true, openArgs = true } }, tDbCommand = moniker }; //Change parameters var tResult = somClient.SetDbCommand(tSet); return tResult; }
See also: