The REPEAT command is beneficial when working with multiple rows or multiple sessions or both. The default database can be specified within the Teradata SQL statement, as with the Teradata 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 Teradata 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;