Programming Guide


Compares widgets in the current table view with their before-image values

#include <tmusubs.h>
int sm_bi_compare(void);



sm_bi_compare compares an occurrence value with its before-image and returns a code indicating the status of the comparison. Comparison codes are listed above.

The occurrence is the current occurrence number as determined by sm_tm_inquire("TM_OCC"). A positive occurrence number indicates an onscreen occurrence. A negative occurrence number indicates a deleted occurrence; an occurrence is deleted by the logical key DELL or by a call to sm_i_doccur.

In the standard transaction models, the requests TM_INSERT, TM_UPDATE, and TM_DELETE each call sm_bi_compare. This allows the model to choose the appropriate processing for a changed occurrence.

A special case exists when a row's primary key value is set to empty or NULL. The program can do this in one of the following ways:

In the standard models both the TM_DELETE and TM_INSERT requests test for BI_KEY_CHANGED and both perform processing for this change. Therefore, if a primary key value changes, the standard models delete the occurrence using the before-image value of the primary key and insert a new occurrence using the onscreen value of the primary key. The model may be changed so that TM_UPDATE handles all updates, including primary key changes.

This function operates on the current table view. It is intended to be called from a transaction model or event function.


/* The following example taken from the standard 
transaction model for JDB shows the processing for the
TM_UPDATE request. */
/* Do nothing, except for updates */
occ_type = sm_bi_compare();
if (occ_type != BI_UPDATED)
	if (!reuse_cursor)
save_cursor_type = 0;
reuse_cursor = 0;