16. Table Fields : Table Field Row States : The CHANGED Row State
 
Share this page                  
The CHANGED Row State
A row in the CHANGED state was originally in the state UNCHANGED because either the user has typed into the row, modifying the original data, or the program has issued a putrow or clearrow statement, again modifying the data. In both of these cases, the row's state becomes CHANGED.
A blank row inserted by the program with an insertrow statement and then filled by the user attains the state CHANGED. Because the state CHANGED provides a useful way to indicate to the program that it must perform an update on a corresponding row in the database, programs that allow the user to insert a blank row (by executing an operation containing an insertrow statement) and fill it with data, must distinguish between a row originally loaded by the program and then changed (which must effect an update to the database) and a row originally blank and then filled by the user (which must effect an insert to the database). The simplest way to provide this capability is to initialize the table field with a hidden column. For all rows originally loaded into the table field from the database, this column can be given a value of 0. Whenever the insertrow statement adds a blank row to the table field, it can give the hidden column a value of 1 to distinguish it from the original rows.