Hi again,
new issue:
Suppose I replace the TMyTable by a TMyStoredProcedure. How do I go about getting the Error reconciliation?
The idea is that I have 4 stored procedures
- spView to view
- spInsert to insert the data
- spUpdate to update the data
- spDelete to delete the data.
I thus connect the spView to the DataSetProvider and set a BeforeUpdateRecord event on the DataSetProvider such that:
Code: Select all
case UpdateKind of
ukInsert :
with spInsert do
{ Cycle through all parameters in the stored proc and match to
fieldname in CDS for assignment }
for i:=0 to ParamCount - 1 do
if Params[i].ParamType = ptInput then
begin
FieldName := Params[I].Name;
if DeltaDS.FindField(FieldName) nil then
Params[I].Value := DeltaDS.FieldByName(FieldName).NewValue;
end;
ExecProc;
Applied := true;
end;
ukModify :
with spUpdate do
{ Cycle through all parameters in the stored proc and match to
fieldname in CDS for assignment }
for I:=0 to ParamCount - 1 do
if Params[I].ParamType = ptInput then
begin
FieldName := Params[I].Name;
if DeltaDS.FindField(FieldName) nil then
{ If NewValue is assigned (either to Null or an updated
value, assign it to the parameter. Otherwise, keep
the OldValue of the field and return it in the
UPDATE statement of the stord proc. }
if (VarIsEmpty(DeltaDS.FieldByName(
FieldName).NewValue)=False) then
Params[I].Value := DeltaDS.FieldByName(FieldName).NewValue
else
Params[I].Value := DeltaDS.FieldByName(FieldName).OldValue;
end;
ExecProc;
Applied:= true;
end;
end;
The problem is that since I set the Applied to true, then no error reconciliation takes place at all. On the other hand, if I do not set it to true, the updates are applied a second time by the ApplyUpdates method. I cannot have the second case as this result in the construction of an SQL statement directly on the table where the record is set and the users do not have the privileges to do insert or select... they can only execute stored procedures...
How would you suggest I implement the OnErrorReconciliation event?
Cheers
________
Uggs