BTEQ - REPEAT command in Teradata

When multiple statements have to be rendered against a database, the REPEAT command will be useful.
For example, if you want to update the salary for multiple employees like below in a BTEQ script,
UPDATE tbl_employee SET salary=2*salary WHERE emp_no=1111;
UPDATE tbl_employee SET salary=2*salary WHERE emp_no=1121;
UPDATE tbl_employee SET salary=2*salary WHERE emp_no=1411;


It will be tedious when multiple statements are present in a script.
BTEQ offers a solution for this problem by giving IMPORT, REPEAT (=) options.

Instead of specifying each statement let us make a single statement, and we will store the employee numbers in a file.
For each employee number in a file the update will happen.

Syntax:
.IMPORT data file = filename;
.REPEAT n;
using variable (datatype)
SQL statement which uses variable from the filename;


Repeat specifies the total number of requests to be submitted.

In our example we want to update the salary for the following employees:
sample.txt
1111
1121
1411


Example:
.LOGON localtd/dbc, dbc;
.IMPORT data file = sample.txt;
.REPEAT 3
using empno (char(4))
UPDATE tbl_employee SET salary=2*salary WHERE emp_no= :empno 


The above code will open the sample.txt file and update the salary for the employee numbers present in the file.