Example: Setting a Query Band Using FOR SESSION VOLATILE - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

This example sets a FOR SESSION VOLATILE query band, verifies that the query band set is what was intended, and then shows that when you specify FOR SESSION VOLATILE, Vantage does not update DBC.SessionTbl, which makes the performance of the FOR SESSION request as good as if it were a FOR TRANSACTION request.

     SET QUERY_BAND = 'city=laquinta;cat=asta;tree=maple;' 
     FOR SESSION VOLATILE;
      *** Set QUERY_BAND accepted. 
      *** Total elapsed time was 1 second.

The query band is now 'city=laquinta;cat=asta;tree=maple;', as the following procedure call demonstrates.

     CALL syslib.GetQueryBandSP(qb);
      *** Procedure has been executed. 
      *** Total elapsed time was 1 second.
     QueryBand
     -----------------------------------------------------------------
     =S> city=laquinta;cat=asta;tree=maple;

The following SELECT request shows that there are no rows in DBC.SessionTbl, which is the desired result when you specify FOR SESSION VOLATILE.

     SELECT queryband 
     FROM DBC.SessionTbl 
     WHERE queryband IS NOT NULL 
     AND   CHAR_LENGTH(queryband) > 0;
*** Query completed. No rows found. 
*** Total elapsed time was 1 second.