Executing Parameteric SQL Object

Below is the example of using the SetDbCommand operation that is used to set parameter values and execute parametric SQL object. The request contains the collection of object parameters. Values are set for input parameters. The response contains execution result with updated information about object parameters.

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">
<SetDbCommand xmlns="http://www.fsight.ru/PP.SOM.Som">
<tDbCommand xmlns="">
  <id>S1!M!S!M3</id>
  </tDbCommand>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
  <openArgs>true</openArgs>
  </pattern>
<meta>
  <type>Unknown</type>
<openArgs>
<args>
<it>
  <k>4294967295</k>
  <id>POPULATION_MIN</id>
  <n>POPULATION_MIN</n>
  <vis>true</vis>
  <value>140000000</value>
  <dt>2</dt>
  </it>
<it>
  <k>4294967295</k>
  <id>POPULATION_MAX</id>
  <n>POPULATION_MAX</n>
  <vis>true</vis>
  <value>150000000</value>
  <dt>2</dt>
  </it>
<it>
  <k>4294967295</k>
  <id>COUNTRY_COUNT</id>
  <n>COUNTRY_COUNT</n>
  <vis>true</vis>
  <dt>2</dt>
  </it>
  </args>
  </openArgs>
  </meta>
<metaGet>
  <obInst>true</obInst>
  <exec>true</exec>
  </metaGet>
  </tArg>
  </SetDbCommand>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<SetDbCommandResult 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!M3</id>
  </id>
<meta xmlns="">
<obInst>
<obDesc ds="" isShortcut="0" isLink="0" ver="1" hf="0">
  <i>OBJ9056</i>
  <n>Function</n>
  <k>9056</k>
  <c>3842</c>
  <p>9050</p>
  <h>0</h>
  <hasPrv>0</hasPrv>
  <ic>0</ic>
  <isPermanent>1</isPermanent>
  <isTemp>0</isTemp>
  </obDesc>
  </obInst>
  <dirty>1</dirty>
  <type>StoredProc</type>
<execResult>
  <rowsAffected>-1</rowsAffected>
<args>
<args>
<it>
  <k>1</k>
  <id>POPULATION_MIN</id>
  <n>POPULATION_MIN</n>
  <vis>1</vis>
  <value>140000000</value>
  <dt>2</dt>
  <binding>UI="IntegerEdit" DIRECTION="Input"</binding>
  </it>
<it>
  <k>2</k>
  <id>POPULATION_MAX</id>
  <n>POPULATION_MAX</n>
  <vis>1</vis>
  <value>150000000</value>
  <dt>2</dt>
  <binding>UI="IntegerEdit" DIRECTION="Input"</binding>
  </it>
<it>
  <k>3</k>
  <id>COUNTRY_COUNT</id>
  <n>COUNTRY_COUNT</n>
  <vis>1</vis>
  <value>1</value>
  <dt>2</dt>
  <binding>UI="IntegerEdit" DIRECTION="ReturnValue"</binding>
  </it>
  </args>
  </args>
  </execResult>
  </meta>
  </SetDbCommandResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"SetDbCommand" :
{
"tDbCommand" :
{
"id" : "S1!M!S!M3"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"openArgs" : "true"
},
"meta" :
{
"type" : "Unknown",
"openArgs" :
{
"args" :
{
"it" :
[
{
"k" : "4294967295",
"id" : "POPULATION_MIN",
"n" : "POPULATION_MIN",
"vis" : "true",
"value" : "140000000",
"dt" : "2"
},
{
"k" : "4294967295",
"id" : "POPULATION_MAX",
"n" : "POPULATION_MAX",
"vis" : "true",
"value" : "150000000",
"dt" : "2"
},
{
"k" : "4294967295",
"id" : "COUNTRY_COUNT",
"n" : "COUNTRY_COUNT",
"vis" : "true",
"dt" : "2"
}
]
}
}
},
"metaGet" :
{
"obInst" : "true",
"exec" : "true"
}
}
}
}

JSON response:

{
"SetDbCommandResult" :
{
"id" :
{
"id" : "S1!M!S!M3"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "1",
"@hf" : "0",
"i" : "OBJ9056",
"n" : "Function",
"k" : "9056",
"c" : "3842",
"p" : "9050",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "1",
"type" : "StoredProc",
"execResult" :
{
"rowsAffected" : "-1",
"args" :
{
"args" :
{
"it" :
[
{
"k" : "1",
"id" : "POPULATION_MIN",
"n" : "POPULATION_MIN",
"vis" : "1",
"value" : "140000000",
"dt" : "2",
"binding" : "UI="IntegerEdit" DIRECTION="Input""
},
{
"k" : "2",
"id" : "POPULATION_MAX",
"n" : "POPULATION_MAX",
"vis" : "1",
"value" : "150000000",
"dt" : "2",
"binding" : "UI="IntegerEdit" DIRECTION="Input""
},
{
"k" : "3",
"id" : "COUNTRY_COUNT",
"n" : "COUNTRY_COUNT",
"vis" : "1",
"value" : "1",
"dt" : "2",
"binding" : "UI="IntegerEdit" DIRECTION="ReturnValue""
}
]
}
}
}
}
}
}
public static SetDbCommandResult ExecuteSQLObject(DbCommandId moniker)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tSet = new SetDbCommand()
{
tArg = new SetDbCommandArg()
{
pattern = new DbCommandMdPattern()
{
openArgs = true
},
meta = new DbCommandMd()
{
openArgs = new OdOpenArgs
{
args = new OdArg[]
{
new OdArg //Output parameter
{
k = uint.MaxValue,
id = "POPULATION_MIN",
n = "POPULATION_MIN",
dt = 2, //DbDataType.Integer
vis = true,
value = "140000000"
},
new OdArg //Output parameter
{
k = uint.MaxValue,
id = "POPULATION_MAX",
n = "POPULATION_MAX",
dt = 2, //DbDataType.Integer
vis = true,
value = "150000000"
},
new OdArg //Parameter, in which calculation result is available
{
k = uint.MaxValue,
id = "COUNTRY_COUNT",
n = "COUNTRY_COUNT",
dt = 2, //DbDataType.Integer
vis = true,
}
}
}
},
metaGet = new DbCommandMdPattern()
{
exec = true
}
},
tDbCommand = moniker
};
//Execute
var tResult = somClient.SetDbCommand(tSet);
return tResult;
}

See also:

SetDbCommand