Initializes before-image data for widgets in the current table view#include <tmusubs.h>int sm_bi_initialize(void);
- · 0: Success. Before-image successfully initialized for the table view or the table view has the
updatableproperty (under Transaction) set to
sm_bi_initializeinitializes or reinitializes before-image data for the widgets in the current table view. Before-image describes the state of transaction data before the user or program changes it.
The transaction commands NEW and SELECT call
sm_bi_initialize. For the
NEWcommand, the before-image for the table view is empty. For the
SELECTcommand, a before-image is defined for each row in the select set.
To initialize the before-image structures, the function first examines the properties of the current table view and the table view's members. It builds the table view's insert list and update list and it verifies that the current table view can participate in the before-image. If a table view has the
updatableproperty set to
PV_YES, it must also have values in the
primary_keyproperties (under Database).
If the Table and Primary Key properties are not set,
sm_bi_initializereturns an error. Furthermore,
sm_bi_initializeverifies that a widget exists for each column named by the table view's
primary_keyproperty. If the widget does not exist in the current table view, the transaction manager looks for a link that names the current table view as a child. The criteria is satisfied if the primary key column is named in the
relationsproperty of the link and that property points to an onscreen widget, a literal, or to a widget in the link's parent table view (or the parent of the server view). Otherwise,
sm_bi_initializereturns an error.
The standard transaction models call
sm_bi_initializeas part of the processing for the
TM_POST_SAVErequest. If an application has saved data while in new or update mode, the models call
sm_bi_initializeafter the save completes. This allows the application to use the current screen data as the starting point for the next save.
For example, assume the application executes sm_tm_command
")to enter new customer data. The user enters the data and the application executes
sm_tm_command("SAVE"). If the save is successful (e.g., it generates and executes a SQL
INSERTstatement), the standard model calls
sm_bi_initializebefore returning control to Panther. To enter the customer's spouse, the user can change the appropriate fields and call
")again. This is also equivalent to calling
Similarly, for the
SELECTcommand, the use of
sm_bi_initializein the standard models allows the application to continue updating the screen data after a save. If customer data is fetched with sm_tm_command
")and the user changes the customer's phone number and calls
sm_tm_command("SAVE"), the model performs save processing (e.g., generates and executes a
SQL UPDATEstatement) and, by default, calls
sm_bi_initialize. The user can continue updating the onscreen data without re-selecting it. If the user enters a comment and calls
sm_tm_command("SAVE")again, the transaction manager performs save processing for all changes since the last call to
sm_bi_initialize. Therefore, it might generate and execute a
SQL UPDATEstatement for the comment; it does not repeat save processing for the earlier phone number change.
This function operates on the current table view. It is intended to be called from a transaction model or event function.