CONNECT (COBOL)

The CONNECT statement establishes a record occurrence as a member of a set occurrence. The specified record must be defined as an optional automatic, optional manual, or mandatory manual member of the set.
idmscu
The CONNECT statement establishes a record occurrence as a member of a set occurrence. The specified record must be defined as an optional automatic, optional manual, or mandatory manual member of the set.
Native VSAM users:
 The CONNECT statement is not valid because all sets in native VSAM data sets must be defined as mandatory automatic.
Before the CONNECT statement executes, the following conditions must be satisfied:
  • All areas that are affected either explicitly or implicitly by the CONNECT statement must be readied in one of the update usage modes (see READY (COBOL)).
  • The specified record must be established as current of its record type.
  • The occurrence of the set into which the specified record will be connected must be established. The current record of set determines the set occurrence and, when set order is NEXT or PRIOR, the position at which the specified record will be connected within the set.
Currency: 
After a CONNECT statement executes successfully, the specified record is current of run unit, its record type, its area, and all sets in which it currently participates.
Syntax
►►─── CONNECT 
record-name
 TO 
set-name
 . ──────────────────────────────────────►◄
Parameters
  • CONNECT 
    record-name
    Specifies the record whose current occurrence is to be connected to the current occurrence of the specified set. This record must be included in the subschema and must be defined as an optional automatic, optional manual, or mandatory manual member of the set to which it is being connected.
  • TO 
    set-name
    Specifies the set to which the member record is to be connected. The set must be included in the subschema. The record is connected to the set in accordance with the ordering rules that are defined for that set in the schema.
Example
The following figure illustrates the steps that are required to connect an EMPLOYEE record to an occurrence of the OFFICE-EMPLOYEE set.
To connect EMPLOYEE 459 to OFFICE 1 in the OFFICE-EMPLOYEE set, establish EMPLOYEE 459 as current of record type, locate the proper occurrence of the OFFICE record, and issue the CONNECT command.
This figure illustrates the steps that are required to connect an EMPLOYEE record to an occurrence of the OFFICE-EMPLOYEE set.
This figure shows the steps for connecting the EMPLOYEE record in table form.
Status Codes
After completion of the CONNECT function, the ERROR-STATUS field in the IDMS communications block indicates the outcome:
Status code
Meaning
0000
The request has been serviced successfully.
0705
The CONNECT would violate a duplicates-not-allowed option.
0706
Currency has not been established for the named record or set.
0708
The named record is not in the subschema. The program has probably invoked the wrong subschema.
0709
The area of the named record has not been readied in one of the update usage modes.
0710
The subschema specifies an access restriction that prohibits connecting the named record in the named set.
0714
The CONNECT statement cannot be executed. The named record has been defined as a mandatory automatic member of the set.
0716
The record cannot be connected to a set in which it is already a member.
0721
An area other than the area of the named record has been readied with an incorrect usage mode.
0725
Currency has not been established for the named set type.