When a Java service, a CICS transaction, and a DSNTEP2 job all hit the same DB2 for z/OS subsystem, accounting traces need more than “someone used plan X”. Client special registers carry extra labels on the connection: who the client claims to be, which application they run, which workstation they sat at, and a correlation token you can search in logs. This page covers all five registers and how they get filled on z/OS.
Authorization still uses RACF, primary and secondary IDs, and CURRENT SQLID. Client registers do not replace that. They add descriptive strings that drivers, middleware, and attachment facilities can set so that:
On Db2 for z/OS you typically read these registers in SQL and write them through APIs. They are not on the list of special registers changed by ordinary SQL SET statements (SET CURRENT SQLID, SET SCHEMA, and friends).
| Register | Data type | Holds |
|---|---|---|
| CURRENT CLIENT_ACCTNG | VARCHAR(255) | Accounting string for the connection |
| CURRENT CLIENT_APPLNAME | VARCHAR(255) | Client application name |
| CURRENT CLIENT_CORR_TOKEN | VARCHAR(255) | Correlation token for this connection |
| CURRENT CLIENT_USERID | VARCHAR(255) | Client user ID (truncated at 128 if longer) |
| CURRENT CLIENT_WRKSTNNAME | VARCHAR(255) | Workstation or hostname label |
The application compatibility (APPLCOMPAT) of the package can change the length and blank padding of ACCTNG, APPLNAME, USERID, and WRKSTNNAME when they are returned. After V11R1, values are not padded to the old short maximums and trailing blanks are removed.
IBM documents these application programming interfaces for changing client information:
If an API is never used, several registers return an empty string when selected. Others have attachment-specific defaults (especially APPLNAME and WRKSTNNAME). Explicit API values overwrite those defaults.
123456SET :ACCT_STRING = CURRENT CLIENT_ACCTNG; SET :WS_NAME = CURRENT CLIENT_WRKSTNNAME; SELECT DEPT FROM DEPT_APPL_MAP WHERE APPL_NAME = CURRENT CLIENT_APPLNAME;
CURRENT CLIENT_ACCTNG (synonym CLIENT ACCTNG) holds the accounting string from client information for the connection. Data type VARCHAR(255).
The accounting string is obtained first from the string set by SET_CLIENT_ID, AUTH SIGNON, or sqleseti. If that string was never set, Db2 can fall back to the RRSAF accounting token.
CICS: the CICS attachment facility normally does not pass an accounting string unless the origin data for the CICS task contains adapter data. When adapter data is present, CICS passes it to Db2 preceded by an eye-catcher such as CICS_ORIGIN_DATA:ADAPTER_DATA_1_2_3: followed by the adapter data.
Empty string is returned if no API (and no CICS origin path) supplied accounting information. Do not assume ACCTNG equals the RACF user ID.
CURRENT CLIENT_APPLNAME (synonym CLIENT APPLNAME) is the application name. Data type VARCHAR(255).
Defaults depend on how you connected:
When the client application name is set explicitly, it overwrites that default.
You can start a statistics class 10 trace (IFCID 411) to monitor remote DRDA applications by CURRENT CLIENT_APPLNAME. Monitoring is limited to 6000 unique application name values. If that limit is exceeded, Db2 issues DSNL030I with reason code 00D3105D and stops collecting statistics for new names until DDF is restarted. IBM recommends CLIENT_CORR_TOKEN to identify individual connections instead of stuffing uniqueness into APPLNAME.
CURRENT CLIENT_CORR_TOKEN holds the client correlation token. Data type VARCHAR(255).
Set it with SQLE_CLIENT_INFO_PROGRAMID (sqleseti), JDBC setClientInfo, or RRSAF SIGNON / AUTH SIGNON / CONTEXT SIGNON / SET_CLIENT_ID. If nothing sets it, the value defaults to a correlation identifier from the client driver (for example an application identifier). If the client system provides no correlation identifier, Db2 generates an LUWID (Logical Unit of Work ID) and that becomes the token.
123SELECT DEPT FROM DEPT_CORR_TOKEN_MAP WHERE CORR_TOKEN_NAME = CURRENT CLIENT_CORR_TOKEN;
Use this register when you need a per-connection handle in your own tables, in traces, and in operator displays. Keep APPLNAME as a stable product or service name (PAYROLL-BATCH, WEB-API) and put the unique request id in CORR_TOKEN.
CURRENT CLIENT_USERID (synonym CLIENT USERID) is the client user ID string. Data type VARCHAR(255), but if the API sets more than 128 bytes, Db2 truncates to 128.
The default is the primary authorization ID used to establish the connection. An explicit client user ID overwrites that default. Middleware often sets this to an end-user id that is not the same as the technical ID that passed RACF.
That overwrite is still only a label. Privileges continue to follow the Db2 authorization IDs and CURRENT SQLID. A forged client user ID does not make you SYSADM.
Statistics class 11 (IFCID 412) can monitor remote DRDA users by this register, also capped at 6000 unique values (DSNL030I reason 00D3105E). Again, prefer CORR_TOKEN for one-row-per-connection identity.
123SELECT DEPT FROM DEPT_USERID_MAP WHERE USER_ID = CURRENT CLIENT_USERID;
CURRENT CLIENT_WRKSTNNAME (synonym CLIENT WRKSTNNAME) is the workstation name. Data type VARCHAR(255).
Defaults:
Explicit API values overwrite the default. If no API is used, a SELECT can still show a default for some attachments; for others the SQL Reference notes an empty string when the register was never set. Always SELECT it in your environment rather than assuming the textbook default.
Before Db2 11, client strings were shorter (examples: accounting 200 bytes, application name 32, user ID 16, workstation 18). With APPLCOMPAT V11R1 or higher, Db2 uses the longer VARCHAR(255) / 128 sizes, does not pad to the old maximum, and strips trailing blanks. Packages at older compatibility can still see truncated values. IFCID 376 function identifiers 1104 (ACCTNG), 1105 (APPLNAME), 1106 (USERID), and 1107 (WRKSTNNAME) flag applications affected by the length change.
RLF search also started using the full length of these registers at V11R1. A limit that used to match a truncated 16-byte CLIENT_USERID might miss the longer value.
When you walk into a library, the librarian already knows your library card (that is USER / RACF). Client registers are the extra stickers you can put on your shirt: “I came from the homework club” (APPLNAME), “I sit at table 4” (WRKSTNNAME), “my teacher’s charge code is 7B” (ACCTNG), “ticket number 9921” (CORR_TOKEN), and “please call me Sam even though the card says SAMUEL01” (CLIENT_USERID). The stickers help the librarian sort the noisy crowd. They do not magically give you keys to the rare-book room.
1. How do you normally set CURRENT CLIENT_ACCTNG on Db2 for z/OS?
2. What is the data type of CURRENT CLIENT_APPLNAME?
3. What happens if CURRENT CLIENT_USERID is set longer than 128 bytes?
4. Why does IBM recommend CLIENT_CORR_TOKEN over APPLNAME for identifying individual connections in traces?
5. If no API sets CURRENT CLIENT_ACCTNG, what does a SELECT of the register return?