3.7 The @@UPID Column in LANSA Created Tables

Whenever a physical table is created and maintained by LANSA, rather than some OTHER system, it has an additional column placed into it. The column is called @@UPID and is defined as decimal (7,0). It is always the last column in the table.

Column @@UPID is used by LANSA to automatically check for "crossed updates". The logic to do this is very simple:

1.  Read the record and save the @@UPID value.

2.  If update required: re-read record and compare the @@UPID with saved @@UPID value. If different issue "crossed update" error message, else add 1 to @@UPID and update the table record.

When writing user application programs in non-LANSA applications, to write new records or update existing records in database tables created by LANSA the following is recommended:

1.  Set @@UPID to 1 when writing new records.

2.  Add 1 to @@UPID when updating an existing record.

This effectively emulates the logic automatically used in all LANSA functions.

Note 1: COBOL programs will not accept the column name @@UPID.
To workaround this problem, if it has not already been done, alter the data dictionary definition of field @@UPID so that it has an associated alias name acceptable to COBOL.
Force recreation of all database tables that do not already have the alias name included and then, in the COBOL programs, use the COPY DD option to ensure that where a field has an alias name, it is used in preference to its real name.

Warning: The field @@UPID should not be used at 4GL level, except where you have received specific instructions from LANSA on how to use it.

Note 2: When a table contains BLOB or CLOB columns, @@UPID may be incremented multiple times for a single UPDATE command. This occurs once for the main table, and once for each BLOB or CLOB column included in the UPDATE command.

Also See

RESET_@@UPID Built-In Function.