REPEAT

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 DATA FILE = 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 ('?','_');

.REPEAT 10
INSERT INTO TESTTABU2 VALUES ('John Doe', 23);

.REPEAT RECS 5
INSERT INTO TESTTABU2 VALUES ('Bob Alice', 21);

.IMPORT DATA FILE = inputData2.dat;
USING (var_1 CHARACTER, var_2 CHARACTER)
INSERT INTO testtabu (c1) VALUES (:var_1) 
;INSERT INTO testtabu (c1) VALUES (:var_2);

Snowflake:

OUT -> Teradata_01.py
#*** Generated code is based on the SnowConvert Python Helpers version 2.0.6 ***
 
import os
import sys
import snowconvert.helpers
from snowconvert.helpers import Export
from snowconvert.helpers import exec
from snowconvert.helpers import BeginLoading
con = None
def main():
  snowconvert.helpers.configure_log()
  con = snowconvert.helpers.log_on()
  snowconvert.helpers.import_file(fr"inputData.dat")
  ssc_repeat_value = '*'
  ssc_max_iterations = 1

  for ssc_repeat_position in range(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 = 10

  for ssc_repeat_position in range(0, ssc_max_iterations):
    exec("""
      INSERT INTO TESTTABU2
      VALUES ('John Doe', 23)
      """)
  ssc_repeat_value = 5
  ssc_max_iterations = 5

  for ssc_repeat_position in range(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"