canSave
Topic group Related topics Example
Event fired when attempting to save the row buffer; return value determines if the buffer is written.
Parameters
none
Property of
Rowset
Description
The row buffer may be saved explicitly by calling save( ) or implicitly, usually by navigating in the rowset. Use canSave to verify that the data is good before attempting to write it to the disk.
The canSave event handler must return true or false to indicate whether the row is saved. If the user has changed the current row and attempts to append a new row or navigate, canAppend or canNavigate fires first. If that event returns true, then the canSave event fires. If canSave returns false, the row is not saved, and the attempted action does not occur. If canSave returns true, then the row is saved and the action occurs. This allows you to put row validation code in the canSave event handler that you do not need to duplicate in either canAppend or canNavigate.
The canSave event operates separately from database engine-level validation. Even if canSave returns true, attempting to write an invalid row, for example one that fails to pass a table contraint, will fail and cause an exception.