AbortSessions Function | Application Programming Reference | Teradata Vantage - AbortSessions - 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™

Aborts any outstanding request or transaction of one or more sessions, and optionally logs those sessions off the database.

If successful, this function returns the number of sessions that were aborted.

Syntax

REPLACE FUNCTION SYSLIB.AbortSessions (
  HostIdIn SMALLINT,
  UserNameIn TD_ANYTYPE,
  SessionNoIn INTEGER,
  LogoffSessions VARCHAR(1) CHARACTER SET LATIN,
  UserOverride VARCHAR(1) CHARACTER SET LATIN
) RETURNS INTEGER
  ... 
;

Syntax Elements

HostIdIn
Logical ID of a host (or client) with sessions logged on. A value of -1 indicates all hosts.
UserNameIn
User name of the session. An asterisk (*) or NULL indicates all users.
SessionNoIn
ID of the session to abort. A value of zero indicates all sessions.
LogoffSessions
Indicator of whether to log off sessions to Vantage in addition to aborting them:
  • Y = Log off and abort sessions.
  • N or NULL = Do not log sessions off.
UserOverride
Indicator of whether to override an ABORT SESSION failure:
  • Y = Override the ABORT SESSION request to fail in any of the following cases:
    • An identified session is being session-switched.
    • An identified session is executing its own ABORT SESSION request.
    • An identified session has a PEState of IDLE: IN-DOUBT as a result of a 2PC.

      Sessions are marked IN-DOUBT by the 2PC protocol, which governs how transactions are committed by multiple systems that do not share memory. The protocol guarantees that either all systems commit or all roll back.

  • N or NULL = Do not override.

Usage Notes

The AbortSessions function provides similar functionality to the PMPC ABORT SESSION request with ListSessions set to ‘Y’ or ‘Yes’. For information about this interface, see ABORT SESSION.

Example: Using AbortSessions

SELECT AbortSessions (1, 'User14', 0, 'Y', 'Y');

Result:

* * * Query completed. One row found. one column returned.
* * * Total elapsed time was 5 seconds.
AbortSessions (1, 'User14', 0, 'Y', 'Y')
----------------------------------------
                                      5

Example: Using AbortSessions with MonitorSession

SELECT AbortSessions (HostId, UserName, SessionNo, 'Y', 'Y');
     FROM TABLE (MonitorSession(-1, '*', 0)) AS t1
WHERE username= 'user14';

Result:

* * * Query completed. 5 rows found. one column returned.
* * * Total elapsed time was 2 seconds.
AbortSessions (HostId, UserName, SessionNo, 'Y', 'Y')
----------------------------------------------------
                                                   1
                                                   1
                                                   1
                                                   1