Skip to content

External view update tracking

This operation records and updates the external-view refresh state for a given image file (identified by ImageFileCode and ImageFileKey). It is used to know whether a document's externally-visible rendering reflects the latest data or is pending an update. Updates are protected by an optimistic concurrency check on UPDATE_NUM.

Field Value
Operation ID OP-IMG-03
Trigger Caller creates a new tracking row via clsImageFileExternalViewUpdate, retrieves an existing one by file code/key, or updates it after the external view date changes
Inputs ImageFileCode, ImageFileKey, external view date, and (for update) the current UpdateNum
Outputs Persisted IMAGE_FILE_EXT_VIEW_UPDATE row (insert), a populated instance (retrieve), or an updated row with an incremented UPDATE_NUM (update)
Primary components clsImageFileExternalViewUpdate.BeforeInsert, clsImageFileExternalViewUpdate.BeforeRetrieve, clsImageFileExternalViewUpdate.BeforeUpdate, clsImageFileExternalViewUpdate.AfterUpdate
Entry point Business\SAIF.Business.Imaging\clsImageFileExternalViewUpdate.vb

Steps

  1. Caller provides ImageFileCode and ImageFileKey to a new clsImageFileExternalViewUpdate instance, along with the external view date to record.
  2. Insert the tracking row. BeforeInsert executes SQL-006 to insert into IMAGE_FILE_EXT_VIEW_UPDATE.
  3. Retrieve an existing tracking row. BeforeRetrieve executes SQL-027 to load the record by ImageFileKey and ImageFileCode.
  4. Update the tracking row. BeforeUpdate executes SQL-035; the WHERE clause requires the row's current UPDATE_NUM value in addition to the file key, functioning as an optimistic concurrency check.
  5. Verify the update. AfterUpdate reads the rows-affected result and raises an error message if it is not exactly one row.
  6. On failure (0 rows affected — the UPDATE_NUM no longer matches): the update is rejected as a concurrency violation, meaning a concurrent update by another session already advanced the row.

Process flow

The following diagram visualizes the external view update tracking operation's control flow.

flowchart TD
    Start([Caller provides ImageFileCode<br>and ImageFileKey]) --> Which{Which action?}
    Which -->|Create| Insert[BeforeInsert: INSERT row]
    Insert --> DoneI([Tracking row created])
    Which -->|Retrieve| Retrieve[BeforeRetrieve by<br>ImageFileKey + ImageFileCode]
    Retrieve --> DoneR([Tracking row loaded])
    Which -->|Update| Update[BeforeUpdate: UPDATE row<br>WHERE current UPDATE_NUM]
    Update --> Check{AfterUpdate:<br>exactly 1 row?}
    Check -->|No| Conflict([Concurrency violation:<br>error raised])
    Check -->|Yes| DoneU([Tracking row updated])

Failure and edge-case behavior

  • clsImageFileExternalViewUpdate.BeforeUpdate requires the current UPDATE_NUM value in the WHERE clause, so concurrent updates by different sessions to the same file key will cause the second update to affect zero rows.
  • AfterUpdate raises an error message when the rows-affected count is not exactly one, surfacing the concurrency conflict to the caller rather than silently no-op'ing.

Sources

  • Business\SAIF.Business.Imaging\clsImageFileExternalViewUpdate.vb