Previous Topic: Database Function

Next Topic: CNT Function Field

Null Update Suppression Logic

The null update suppression logic generated in CHGOBJ functions determines whether to update the database record as shown in the following steps:

  1. Before the After Data Read user point, CHGOBJ saves an image of the original data record and initializes the *Record data changed PGM context field to ‘ ‘.
  2. CHGOBJ performs the following checks.

    If the images differ and the *Record data changed field is not *NO, CHGOBJ sets the *Record data changed field to *YES.

    Note: Where and how often the previous checks are done within the CHGOBJ depends on whether YNLLUPD is *AFTREAD or *YES. If *YES, check is done both after the After Data Read and after the Before Data Update user points. If *AFTREAD, the check is done only after the After Data Read user point.

  3. Before updating the database record, CHGOBJ checks the *Record data changed PGM context field. If it is *YES, the database record is updated, otherwise the record is released.

For more information about:

It is possible to change the primary key of a file using CHGOBJ. However, this is only valid for RPG/DDS and this generally violates relational database principles. Changing the primary key should be performed using DLTOBJ function followed by a CRTOBJ function. In COBOL or SQL, a primary key change must be performed in this way.

For a given based-on access path, if you want to update all database fields in some functions but only a subset of fields in other functions, create a second CHGOBJ function by copying the default CHGOBJ function. On the second CHGOBJ, specify the fields you do not want to update as Neither (N) parameters. Only fields specified as Input (I) parameters are updated in the database record. Use the second CHGOBJ instead of the default CHGOBJ in the functions where you want to update the subset of the database fields.

For more information about: