SetChanges

Description

Applies changes captured with GetChanges to a DataWindow or DataStore. This method is used primarily in distributed applications.

Applies to

DataWindow type

Method applies to

PowerBuilder

DataWindow control, DataStore object


Syntax

PowerBuilder

long dwcontrol.SetChanges ( blob changeblob {, dwConflictResolution resolution } )

Argument

Description

dwcontrol

A reference to a DataWindow control or DataStore.

changeblob

A read-only change blob created with GetChanges from which you want to apply changes.

resolution (obsolete)

A value of the dwConflictResolution enumerated datatype indicating how conflicts should be resolved:

  • FailOnAnyConflict! (default)

  • AllowPartialChanges!

This argument is obsolete and will be disabled in a future release.


Return value

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:

// Instance variable:datastore ids_datastore
// Function argument: blob ablb_data
long ll_rv
 
ids_datastore.SetChanges(ablb_data)
ll_rv = ids_datastore.Update()
 
IF ll_rv > 0 THEN
      COMMIT;
ELSE
      ROLLBACK;
END IF 
RETURN ll_rv

See also

GetChanges

GetFullState

GetStateStatus

SetFullState