SetChanges method (DataWindows)
Description
Applies changes captured with GetChanges to
a DataWindow or DataStore. This method is used primarily
in distributed applications.
Controls
|
DataWindow type |
Method applies to |
|---|---|
|
PowerBuilder |
DataWindow control, DataStore object |
|
Web ActiveX |
DataWindow control |
Syntax
[PowerBuilder]
|
1 |
long <span>dwcontrol</span>.<span>SetChanges</span> ( blob <span>changeblob </span>{, dwConflictResolution <span>resolution } </span>) |
[Web ActiveX]
|
1 |
number <span>dwcontrol</span>.<span>SetChanges</span> ( string <span>changeblob</span>, number <span>resolution </span> ) |
|
Argument |
Description |
|---|---|
|
dwcontrol |
A reference to a DataWindow control or |
|
changeblob |
A read-only change blob created with |
|
resolution (obsolete) |
A value of the dwConflictResolution enumerated
This |
Return Values
Returns one of the following values:
-
1
All changes were applied
-
2
A partial update was successful; conflicting changes were
discarded -
-1
Method failed
-
-2
There is a conflict between the state of the DataWindow changeblob and
the state of the DataWindow -
-3
Column specifications do not match
If any argument’s value is null, in PowerBuilder
and JavaScript the method returns null.
Usage
Use this method in conjunction with GetChanges to
synchronize two or more DataWindows or DataStores. GetChanges retrieves
data buffers and status flags for changed rows in a DataWindow or
DataStore and places this information in a blob. SetChanges then
applies the contents of this blob to another DataWindow or DataStore.
Calling SetChanges when no changes are pending
GetChanges returns 0 if no changes are
pending. This can happen if AcceptText is not
called after rows are modified. In this case, calling SetChanges will
fail, with a return code of –1.
If you call GetChanges on a DataWindow
and apply the data passed in the changeblob argument
to another DataWindow using SetChanges, you must
call GetChanges on the second DataWindow before
you reapply changes to it from the first DataWindow. The GetChanges call
on the second DataWindow updates the original timestamp on that
DataWindow so that it matches the current timestamp. (You cannot
use the Reset, ResetUpdate,
or AcceptText calls to update the original timestamp.)
If you try to reapply changes without first calling GetChanges on
the second DataWindow, you will get an error due to the conflict
between the state of the DataWindow changeblob and
the state of the second DataWindow.
Examples
The following example is a script for a remote object
function. The script uses SetChanges to apply
changes made to a DataWindow control on a client to a DataStore
on a server. The changes made on the client are contained in a change
blob that is passed as an argument to the function. After applying
changes to the DataStore, the server updates the database:
|
1 |
// Instance variable:datastore ids_datastore |
|
1 |
// Function argument: blob ablb_data |
|
1 |
long ll_rv |
|
1 |
|
1 |
ids_datastore.<span>SetChanges</span>(ablb_data) |
|
1 |
ll_rv = ids_datastore.Update() |
|
1 |
|
1 |
IF ll_rv > 0 THEN |
|
1 |
COMMIT; |
|
1 |
ELSE |
|
1 |
ROLLBACK; |
|
1 |
END IF |
|
1 |
RETURN ll_rv |