Example: Using UPDATE with a FOR SESSION VOLATILE Query Band - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

This example sets a FOR SESSION VOLATILE query band with the UPDATE option, verifies that the query band set is what was intended, and then shows that the existing query band has been updated to add the name:value pairs area=west, city=sandiego, tree=maple, and flower=rose.

Following is the initial SET QUERY_BAND to set the query band and write to DBC.SessionTbl.

SET QUERY_BAND = 'area=west;city=sandiego;tree=maple;flower=rose;' FOR SESSION;

Following is the SET QUERY_BAND statement with the UPDATE option.

     SET QUERY_BAND = 'cat=siamese;dog=akita;' 
     UPDATE FOR SESSION VOLATILE;
      *** Set QUERY_BAND accepted. 
      *** Total elapsed time was 1 second.

The query band is now 'cat=siamese;dog=akita;area=west;city=sandiego;tree=maple;flower=rose' as the following procedure call demonstrates.

     CALL syslib.GetQueryBandSP(qb);
      *** Procedure has been executed. 
      *** Total elapsed time was 1 second.
   QueryBand
   -------------------------------------------------------------------
   =S>    cat=siamese;dog=akita;area=west;city=sandiego;tree=maple;flower=rose;

DBC.SessionTbl must have only one row, which must be for the following query band:

     'city=sandiego;flower=rose;area=west;cat=asta;tree=maple;' 

The following SELECT request shows that DBC.SessionTbl has only the expected row:

     SELECT queryband 
     FROM DBC.SessionTbl 
     WHERE queryband IS NOT NULL 
     AND   CHAR_LENGTH(queryband) > 0;
      *** Query completed. One row found. One column returned. 
      *** Total elapsed time was 1 second.
     QueryBand
     -----------------------------------------------------------------
     city=sandiego;flower=rose;area=west;cat=asta;tree=maple;