Products Downloads


French version


 

 

ADELIA

VADELIA

SADELIA

WADELIA

MADELIA

(I/B)

(I/B) (S)

(B) (S)

(I/B) (S)

(I) (S)

 

Section for use

All

 

Syntax

CHAIN ViewName Option Parameter

 

Option

Þ

*UNLCK | None

 

 

 

Parameter

Þ

*NO_MR | *MR | None

 

Description

This instruction corresponds to a file read by key or by record number. A view ViewName must have been previously defined as having access by key (or direct), and the access key must correspond to the file key.

 

It is possible to test whether the reading was successful by an instruction of the type:

 

IF ViewName EXISTS

or

IF ViewName DOES_NOT_EXIST.

 

If the read operation is not completed successfully, the system will not read any records at all, and the values of the file fields will remain unchanged.

 

You can also check that the record is not locked, by testing it with the *LOCKED reserved word:

If *LOCKED = 1

The record is locked.

If *LOCKED = 0

The record is not locked.

 

By default, file records are locked after being read if the file's view ViewName is declared in update mode and the *UNLCK reserved word is not used.

See the UNLOCK instruction which enables a file record to be released.

 

IF *UNLCK is mentioned, the reading does not lock the record. This parameter, used on a file opened in update mode, enables the same effect as if it had been declared in read-only mode.

 

The *MR parameter allows you to generate read implicit management rules that are linked to the entity corresponding to the view, even if the program is generated without the option to generate implicit management rules.

 

The *NO_MR parameter allows you not to generate read implicit management rules that are linked to the entity corresponding to the view, even if the program is generated with the option to generate implicit management rules.

 

Example

Example for SALES file (file keys are: customer code and line number).

SALES view is used with W_CUST_CODE and W_LINE_NBR as access keys.

 

SALES_CUST_CODE

SALES_LINE_NBR

0002

01

0002

02

0002

03

0002

04

0006

01

0006

02

0011

01

 

W_CUST_CODE = '0006'

W_LINE_NBR = '01'

CHAIN SALES

IF   SALES DOES_NOT_EXIST

PREPARE_MSG 0024 W_CUST_CODE

ERROR

END

* This will position the pointer in the file on customer 0006 / line 01

* The record exists, so message 0024 will NOT be sent

*

W_CUST_CODE = '0006'

W_LINE_NBR = '03'

CHAIN SALES

IF   SALES DOES_NOT_EXIST

PREPARE_MSG 0024 W_CUST_CODE

ERROR

END

* The record does not exist, so message 0024 will be sent

*

 

Other example:

 

CHAIN ORDHEADER_DA

IF   ORD_HEADER_DA EXISTS

* lock test

IF *LOCKED = '1'

PW_RET_COD = 'DN'

ELSE

PRESENT ORDHEADER_DA

CHAIN CUSTOMER_DB

...

END

END

 

↑ Top of page


  • Aucune étiquette