Explicitly Establishing a Session
Before Teradata Database can process requests, one or more sessions must be established on a server. If a large number of sessions need to be simultaneously connected by an application, the DBCISMAX setting should reflect this when the first session is connected. Doing so will improve performance by allowing CLIv2 to optimize its internal processing. To establish a session, an application must perform the following
1 Modify the DBCAREA.
a Set the Function to CONNECT.
b Optionally, set the following:
- Mechanism‑data‑len
- Mechanism‑data‑ptr
- Mechanism‑data‑encoding
- Delegate‑user‑identity
c If required, set the Logon Pointer.
d If required, set the Logon Length.
e Optionally set the following:
2 Call DBCHCL to perform the Connect function.
3 Check the return code from DBCHCL.
Connect Type |
Return Code |
Result |
R |
33 |
A session is established and the Teradata SQL processing can continue. |
0 |
Process the failure/error parcels. |
|
anything else |
An abnormal situation occurred. Use the Fetch function (“Fetching the Response for a Request” on page 58) to process. |
|
C |
0 |
Process parcels from Teradata Database. If a success parcel returns, then a session is established and Teradata SQL processing can continue. If anything else returns, process the failure/error parcel. |
anything else |
An abnormal situation occurred. Use the Fetch function (“Fetching the Response for a Request” on page 58) to process. |
4 Call DBCHCL to perform the End Request function (see “Ending a Request” on page 61).
If the Connect attempt is not successful at any point, the program can retry the Connect after calling DBCHCL for the End Request function.
If the application requires multiple active requests, multiple sessions can be established by following the aforementioned steps for each session desired.
In addition, the Session Id field in the DBCAREA should be saved to request Teradata SQL processing for that session at a later time.