16.20 - Example: Initiating a Trusted Session Using a Transaction Query Band - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Data Definition Language Syntax and Examples

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-24
dita:mapPath
wkf1512081455740.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval

Using the transaction query band, you can change the proxy user within an explicit Teradata session mode transaction. In this example, proxy user bob initially has the INSERT privilege on bobs_table, but then that query band is replaced within the transaction with a new query band that enables proxy user joe to have the INSERT privilege on joes_table.

At first glance this example seems trivial, but the capability it demonstrates is very useful for use with Java applets.

     BEGIN TRANSACTION;
       SET QUERY_BAND = 'PROXYUSER=bob;' FOR TRANSACTION;
       INSERT INTO bobs_table VALUES(1, 2, 3);
       SET QUERY_BAND = 'PROXYUSER=joe;' FOR TRANSACTION;
       INSERT INTO joes_table VALUES(a, b, c);
     END TRANSACTION;