Secure

Syntax

SECURE

Description

The Secure command option can be specified with the ForEach, Determine, and LookUp logic commands and variants to facilitate record-level locking of the database in applications that do not force integrity.

If the segment's Integrity property set to true, all of its classes automatically secure all required resources anyway, and use of the Secure command option is meaningless. An individual class might also have its Integrity property set to true. In this case, the same applies to that class.

When the Secure command option is used, the record remains locked until end-of-transaction, or if the class is a report, until end-of-job or a CriticalPoint logic statement is executed.

A lock applied to a record prevents other users from updating that record. Other users wanting to update that record (whether they are enforcing integrity or not) are forced to wait until the transaction is complete before their update is processed. For applications using SQL Server, other users are also prevented from reading the locked record.

Restrictions

Use of the Secure command option and the KeyOnly command option in the same logic statement is mutually exclusive.

Due to SQL Server's lock escalation, records other than those read into memory might also be locked. Refer to the SQL Server documentation for more information on lock escalation.

Example

A report is initiated using a Run logic statement in ispec logic. The ispec stores parameters in the RPram ispec, an automatic entry. This ispec is accessed by the report through the PrinParam profile, which has the following condition:

RPram.BeenRead <> "X"

Since several copies of the Invoice report might be running at the same time, it is essential that each set of parameters is processed only once.

Determine From RParam.PrinParam (Invoice) Secure
   MyDataField := RPram.MyAttribute
      : Logic
   Flag "X" RPram.BeenRead       : Flag the record off the profile
   Break
End
CriticalPoint                    : Free the record (if required)

Different reports could use the same runtime parameter file, by using a report identifier as one of the profile keys.