Dear All:
Brand new to SmartClient and have some problem about data operation.
I read the doc and find it just introduce the type of it, like fetch,update, remove and add.
I hope to get some examples of it.(About how to use operationType transferring the store procedure. fancycgx3650@126.com, it is my email)
In the below xml, if I use it to transfer a store procedure (SP_UpdateBudgetDist)
And in the file of js, I use ds.removeData() to get the operationtype of remove, but it is not use primaryKey (budgetDistId).
Will is be wrong?
<DataSource ID="budgetDistDS" serverType="sql" tableName="BudgetDist">
<fields>
<field name="budgetDistId" type="sequence" title="Id" hidden="true" primaryKey="true" />
<field name="budgetItemId" type="text" title="Name" />
<field name="accountCode" type="text" title="Year" required="false" />
<field name="budgetDistTypeId" type="text" title="Department" />
</fields>
<operationBinding operationType="remove">
<customSQL>SP_UpdateBudgetDist $criteria.budgetItemId, $criteria.budgetDistTypeId, $criteria.itemsXML</customSQL>
</operationBinding>
CODE]
Look at the server logs to see if the values you want to use are actually being transmitted. Always post such logs, as well as all relevant versions, whenever you post.
I tried it just now. And there are some problems.
The following is the error:
WARN:RPCManager:Criteria received from the client for remove operation is missing the following required unique and/or primary fields: [budgetDistId]. Either provide all primary key fields or set allowMultiUpdate on the OperationBinding, response: {operationId: “custom”,}
The following is my datasource of xml:
<DataSource ID="budgetDistDS" serverType="sql" tableName="BudgetDist">
<fields>
<field name="budgetDistId" type="sequence" title="Id" hidden="true" primaryKey="true" />
<field name="budgetItemId" type="text" title="Name" />
<field name="accountCode" type="text" title="Year" required="false" />
<field name="budgetDistTypeId" type="text" title="Department" />
</fields>
<operationBindings>
<operationBinding operationType="remove">
<customSQL>SP_UpdateBudgetDist $criteria.budgetDistId, $criteria.budgetItemId, $criteria.budgetDistTypeId, $criteria.itemsXML</customSQL>
</operationBinding>
</operationBindings>
</DataSource>
The following is the code I use to transfer the store procedure:
closeClick : function () {
var xml ;
var ds = isc.DataSource.get("budgetDistDS");
ds.removeData(1,2,3,xml);
},
See the docs for removeData(), you aren’t passing parameters that match the signature. If you wanted to pass data to allow that SQL template to work, it would be more like:
ds.removeData({
budgetItemId:1,
budgetDistTypeId:2,
itemsXML:xml
})
Dear Admin:
I saw the doc and tried it again just now.
the parameter of removeData is just primaryKey, if I transfer some else parameters, It appear the error that “there is some error near $criteria”.
if I just transfer the primaryKey budgetDistId, it is OK.
And I just want to use a store procedure, so I will try another way to work out it, I will show it succeed or not later.
Removes are limited to primary keys as criteria by default as a security measure. You could declare the operation as either “update” (and then use $values in lieu of $criteria).