Declaring the SQLSESS Host Variable
To implement concurrent sessions, the program must declare a host variable to which CA IDMS assigns the session identifier of the active SQL session:
EXEC SQL BEGIN DECLARE SECTION END-EXEC. 01 IDMS-SESS-ID USAGE SQLSESS. EXEC SQL END DECLARE SECTION END-EXEC.
Saving the Session ID Value
The precompiler expands the SQLSESS host variable to an 8-byte character field. Therefore, to save session ID values, the application program must define work fields that also are 8-byte character fields:
WS-SESSION-IDS. 05 SESS1-ID PIC X(8). 05 SESS2-ID PIC X(8).
Multiple Session Steps
These are the steps in a typical scenario for managing multiple sessions:
At this point, the current session ID value is the one representing the second session. To make the first session the current session, the application program would move the value in SESS1-ID to IDMS-SESS-ID.
Multiple Sessions Started by One Program
The following diagram illustrates a scenario in which a program manages session IDs to maintain multiple concurrent sessions.
In this case, the mainline program initiates both sessions and passes the appropriate session ID to each subordinate program to indicate which session the subprogram should process. Each subprogram must also declare a session identifier to hold the value passed from the mainline program.
Mainline ┌────────────────────────────────────────┐ │ Connect to DB01 │ │ Save first session value │ │ Initialize SQLSESS │ │ Connect to DB02 │ │ Save second session value │ Program1 │ Move first session value to SQLSESS │ ┌────────────────────────┐ │ Call PROGRAM1 passing SQLSESS ──────┼──────►... │ │ │ │LINKAGE SECTION. │ │ │ │EXEC SQL │ │ │ │ BEGIN DECLARE SECTION │ │ │ │END-EXEC. │ │ │ │01 SQLSESS USAGE SQLSESS│ │ │ │EXEC SQL │ │ │ │ END DECLARE SECTION │ │ │ │END-EXEC. │ │ │ │... │ │ ◄─────┼──────┤SQL statements for DB01 │ │ │ └────────────────────────┘ │ │ │ │ Program2 │ Move second session value to SQLSESS │ ┌────────────────────────┐ │ Call PROGRAM2 passing SQLSESS ──────┼──────►... │ │ │ │LINKAGE SECTION. │ │ │ │EXEC SQL │ │ │ │ BEGIN DECLARE SECTION │ │ │ │END-EXEC. │ │ │ │01 SQLSESS USAGE SQLSESS│ │ │ │EXEC SQL │ │ │ │ END DECLARE SECTION │ │ │ │END-EXEC. │ │ │ │... │ │ ◄─────┼──────┤SQL statements for DB02 │ │ │ └────────────────────────┘ │ FINISH TASK │ └────────────────────────────────────────┘
Multiple Sessions Started by Different Programs
The following diagram illustrates a scenario in which multiple sessions are begun by multiple programs.
In this case, Program 1 must declare a session ID to indicate that a separate session is desired; otherwise, the CONNECT statement will return an error. However, no manipulation of the session ID is required.
Mainline ┌────────────────────────────────────────┐ │ │ │ │ Program1 │ Connect to DB01 │ ┌────────────────────┐ │ Call PROGRAM1 ──────┼──────► Connect to DB02 │ │ │ │ Retrieve data │ │ ◄─────┼──────┤ COMMIT RELEASE │ │ │ └────────────────────┘ │ Update data in DB01 │ │ COMMIT RELEASE │ └────────────────────────────────────────┘
Copyright © 2013 CA.
All rights reserved.
|
|