SetSessionAccount Function | Application Programming Reference | Teradata Vantage - SetSessionAccount - Teradata Vantage - Analytics Database

Application Programming Reference

Deployment
VantageCloud
VantageCore
Edition
VMware
Enterprise
IntelliFlex
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
qld1628112131956.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
ajo1472244909562
lifecycle
latest
Product Category
Teradata Vantageā„¢

Changes the account string for the session or for the request.

This function returns the old account string.

Syntax

REPLACE FUNCTION SetSessionAccount (
  HostIdIn SMALLINT,
  SessionNoIn INTEGER,
  NewAcctString TD_ANYTYPE,
  EntireSession VARCHAR(1) CHARACTER SET LATIN
) RETURNS VARCHAR(128) CHARACTER SET UNICODE
  ...
;

Syntax Elements

HostIdIn
Logical ID of a host (or client) with sessions logged on.
SessionNoIn
Number of the specified session.
NewAcctString
Account string for the session or request.
EntireSession
Indicator of how the new account or priority affects requests for a specified session.
If you specify Y or y, the change applies to all current and future requests for a specified session. If no requests or steps are executing, the new account or priority takes effect at the next request, and the DBC.SessionTbl table reflects the new account or priority for the current session.
If you specify NULL, blank, N, or n, the change applies only to the current request for the specified session. If no request is executing, the next request for the specified session has the old account/priority.

Usage Notes

The SetSessionAccount function provides similar functionality to the PMPC SET SESSION ACCOUNT request. For information about this interface, see SET SESSION ACCOUNT.

Example: Using SetSessionAccount with MonitorSession

BTEQ -- Enter your DBC/SQL request or BTEQ command:
SELECT SetSessionAccount(Hostid, sessionno, 'Accountx','Y')
FROM TABLE (MonitorSession(1,'twmuser3',0)) AS t1;
SELECT SetSessionAccount(Hostid, sessionno, 'Accountx','Y')
FROM TABLE (MonitorSession(1,'twmuser3',0)) AS t1;
 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.
SetSessionAccount(HostId,SessionNo,'Accountx','Y')
--------------------------------------------------
ACCOUNT3 

Example: Using SetSessionAccount

BTEQ -- Enter your DBC/SQL request or BTEQ command:
SELECT SetSessionAccount(1, 4461, 'Account3','y');
SELECT SetSessionAccount(1, 4461, 'Account3','y');
 *** Query completed. One row found. One column returned.
 *** Total elapsed time was 1 second.
SetSessionAccount(1,4461,'Account3','y')
----------------------------------------
ACCOUNTX