Translation specification for the REPEAT statement.
Some parts in the output code are omitted for clarity reasons.
As per Teradata's documentation, the REPEAT statement enables users to specify the maximum number of times the next SQL request is to be submitted. Note that a SQL request can be a single or multi-statement request. This is defined by the position of the semicolons for each statement following the REPEAT statement.
Syntax
REPEAT [ n [ PACK p [ REQBUFLEN b ] ] | * | RECS r]
<sql_request>
Sample Source Patterns
With this input data:
A B C
D E F
G H I
* [
] *
Teradata:
IN -> Teradata_01.bteq
.IMPORT DATAFILE= inputData.dat;.REPEAT*USING var_1 (CHARACTER), var_2 (CHARACTER), var_3 (CHARACTER)INSERT INTO testtabu (c1) VALUES (:var_1);INSERT INTO testtabu (c1) VALUES (:var_2) ;INSERT INTO testtabu (c1) VALUES (:var_3) ;UPDATE testtabu SET c2 ='X'WHERE c1 = :var_1 ;UPDATE testtabu SET c2 ='Y'WHERE c1 = :var_2 ;UPDATE testtabu SET c2 ='Z'WHERE c1 = :var_3;INSERT INTO TESTTABU (c1, c2) VALUES ('?','_');.REPEAT10INSERT INTO TESTTABU2 VALUES ('John Doe', 23);.REPEAT RECS 5INSERT INTO TESTTABU2 VALUES ('Bob Alice', 21);.IMPORT DATAFILE= inputData2.dat;USING (var_1 CHARACTER, var_2 CHARACTER)INSERT INTO testtabu (c1) VALUES (:var_1) ;INSERT INTO testtabu (c1) VALUES (:var_2);
C1
C2
A
X
D
X
G
X
B
Y
E
Y
H
Y
C
Z
F
Z
I
Z
?
_
?
_
?
_
*
null
[
null
MY_NAME
MY_AGE
John Doe
23
John Doe
23
John Doe
23
John Doe
23
John Doe
23
John Doe
23
John Doe
23
John Doe
23
John Doe
23
John Doe
23
Bob Alice
21
Bob Alice
21
Bob Alice
21
Bob Alice
21
Bob Alice
21
Snowflake:
OUT -> Teradata_01.py
#*** Generated code is based on the SnowConvert Python Helpers version 2.0.6 ***import osimport sysimport snowconvert.helpersfrom snowconvert.helpers import Exportfrom snowconvert.helpers importexecfrom snowconvert.helpers import BeginLoadingcon =Nonedefmain(): snowconvert.helpers.configure_log() con = snowconvert.helpers.log_on() snowconvert.helpers.import_file(fr"inputData.dat") ssc_repeat_value ='*' ssc_max_iterations =1for ssc_repeat_position inrange(0, ssc_max_iterations):if ssc_repeat_position ==0: using = snowconvert.helpers.using("var_1", "CHARACTER", "var_2", "CHARACTER", "var_3", "CHARACTER", rows_to_read = ssc_repeat_value)exec(""" INSERT INTO testtabu (c1) VALUES (:var_1) """, using = using)exec(""" INSERT INTO testtabu (c1) VALUES (:var_2) """, using = using)exec(""" INSERT INTO testtabu (c1) VALUES (:var_3) """, using = using)exec(""" UPDATE testtabu SET c2 = 'X' WHERE c1 = :var_1 """, using = using)exec(""" UPDATE testtabu SET c2 = 'Y' WHERE c1 = :var_2 """, using = using)exec(""" UPDATE testtabu SET c2 = 'Z' WHERE c1 = :var_3 """, using = using)exec(""" INSERT INTO TESTTABU (c1, c2) VALUES ('?', '_') """, using = using) ssc_repeat_value =10 ssc_max_iterations =10for ssc_repeat_position inrange(0, ssc_max_iterations):exec(""" INSERT INTO TESTTABU2 VALUES ('John Doe', 23) """) ssc_repeat_value =5 ssc_max_iterations =5for ssc_repeat_position inrange(0, ssc_max_iterations):exec(""" INSERT INTO TESTTABU2 VALUES ('Bob Alice', 21) """) snowconvert.helpers.import_file(fr"inputData2.dat") using = snowconvert.helpers.using("var_1", "CHARACTER", "var_2", "CHARACTER", rows_to_read =1)exec(""" INSERT INTO testtabu (c1) VALUES (:var_1) """, using = using)exec(""" INSERT INTO testtabu (c1) VALUES (:var_2) """, using = using) snowconvert.helpers.quit_application()if__name__=="__main__":main()