How to Use REPEAT with Multiple Sessions | Basic Teradata Query - Using REPEAT with Multiple Sessions - Basic Teradata Query

Basic Teradata® Query Reference

Product
Basic Teradata Query
Release Number
17.00
Published
December 2020
Language
English (United States)
Last Update
2020-12-12
dita:mapPath
zqt1544831938740.ditamap
dita:ditavalPath
obe1474387269547.ditaval
dita:id
B035-2414
lifecycle
previous
Product Category
Teradata Tools and Utilities

The REPEAT command is beneficial when working with multiple rows or multiple sessions or both. The default database can be specified within the SQL statement, as with the SQL UPDATE statement in prior examples. Another way to define the default database is to enter the REPEAT command with the number of sessions before the SQL DATABASE statement.

For example, to run two concurrent sessions that update the Employee table in the Workforce database, enter the following script:

.SET sessions 2
.REPEAT 2 
database workforce;
.IMPORT data file=raiseemp 
.REPEAT 2
using enumb (char(5))
update employee set salary=salary*1.07
where empno=:enumb;

The first REPEAT command specifies the default database for both sessions. The second REPEAT command runs the two sessions until the entire table is updated. Without specifying the first REPEAT command, only the first session would use the Workforce database; the other session would not have a defined database.

The following example reflects the use of the REPEAT command to ensure multiple sessions are established with the same query band. For the following example, propagation of a set query band is not automatic across sessions.

.SET SESSIONS 3
.LOGON MyDB/MyID,MyPW;
.REPEAT 3
SET QUERY_BAND= 'MyNAME=12345;' FOR SESSION;