REPEAT (REP)


The REPEAT command adds one or more duplicate rows to a table. It is valid only in Edit row mode. (Use the REPEAT line command when in Edit table mode.)

When your user profile has the Repeat Command Prompt set to ON (see PROFILE-PRO) the REPEAT Column Range Specification window displays (see REPEAT Window), except when you are editing Unicode table data.

If you repeat the row more than once, you must issue the NEXT command to view the additional rows.

The added row is indicated by the message under the COMMAND field, Row Repeat Pending. The row is placed in a pending state, allowing you to make any further changes until the data is saved.

image2021-3-9_17-33-39.png

nnnnn

Repeats the row nnnnn number of times. Defaults to one row.

Important

While you can repeat a row up to 99,999 times, consider possible consequences, for example not sufficient memory allocation, before issuing a high repeat value.

REPEAT Window

The REPEAT Column Range Specification window (REPEAT Column Range Specification Window) provides additional rapid data generation functionality. It works similar to the CHANGE command window (see CHANGE Command Window ). Just specify an increment for a column value. File-AID for Db2 will repeat the row the specified number of times with the incremented values filled in the column.

The REPEAT Column Range Specification window is displayed when your user profile has the Repeat Command Prompt set to ON (see PROFILE-PRO), and you are not editing Unicode table data. The screen prefills the Repeat field (1), the Column name field (last selected column, or first column in primary key, or first column) and the Initial value field (selected column’s data).

Important

The REPEAT Column Range Specification window is NOT displayed when you are editing Unicode table data, even when the Repeat Command Prompt is set to ON. In this situation, all repeated rows are identical to the original row, and you are required to update Key values as necessary.

After you make your changes to the fields, press Enter on this screen to process the repeat request and exit the window. If you want the rows repeated without changed column data, do not change any fields and press Enter. Press END to cancel the REPEAT command and exit the window.

REPEAT Column Range Specification Window

image2021-3-9_17-35-3.png

Repeat

Enter the number of times the row should be repeated. Default is 1. If you entered the REPEAT n command the value for n is prefilled.

Column name

Name of the Db2 column in which you want to apply the column range increment. The first column in primary key or first column is prefilled by default. Entering an asterisk (*) presents a list of columns from which you select a column name. You can also enter partial column names. If more than one column name matches the criteria, a window displays all matching columns, allowing you to select one. See Column Selection window for a sample window. You must specify a column name, or you receive an error message.

Initial Value

Value in the selected column for the first repeated row. Prefilled with the selected column’s data (maximum 40 characters, including quotes).

Important

The initial value will replace the entire column’s value even when the column length is greater than 40. Blank out this field when you do not want to change the column’s value.

Enclose the initial value in either single or double quotes when:


    • the initial value contains blanks
    • the initial value matches the characters of reserved words, but you only want to use these words as constants, not as reserved words. Valid reserved words for the REPEAT command are:

CUR

CURR

CURRENT

CURRENT DATE

CURRENT_DATE

CURRENT TIME

CURRENT_TIME

CURRENT TIMESTAMP

CURRENT_TIMESTAMP

USER

NULL

NULLS


    • the initial value contains a single quote (’), you must enclose it in double quotes
    • the initial value contains double quotes ("), you must enclose it in single quotes
    • the initial value must not be changed to uppercase characters

To specify a hexadecimal value, enclose the string in single or double quotes and preface with an X. To specify a null value, enter NULL. To specify a case sensitive string, enclose the string in quotes and preface it with a C.

When you also fill in a value in the Increment by field the initial value will be modified and incremented for all repeated rows. For example, 100 is the initial value for the Employee Number. This value is used as the base for the modification. Then, the Increment by value, for example 10, modifies the initial value. Thus, the following Employee Number values of a four (4) time repeat will be 110 (first new row), 120, 130, and 140. The new value must fit the required format and length for the selected column, or you receive an error message.

Increment by

Increment to modify alphabetic (a through z) and numeric characters (0 through 9) of the initial value. Other characters (e.g %, #, =, etc.) are not changed by the increment value. The default increment is blank (no increment). The increment is always a numeric value. A negative value, for example (-1) is valid and will decrease from the initial value (100 initial value: 99, 98, 97, etc.). Positive increment is assumed and must be entered without a sign.

The column data type determines how increments are interpreted. Date and time actually have additional pop-up displays (see Timestamp Pop-up WindowTime Pop-up Window, and Date Pop-up Window).

Important

Date and time increments always result in valid Db2 date and time values. For example, if you use a one month increment for a starting date of 1998/01/31, the resulting dates are 1998/01/31, 1998/02/28, 1998/03/28, etc.

Specify an increment when you want to repeat a row with one REPEAT command and avoid duplicate data.

When the initial value is an alpha character, for example A, and the increment is 2, the resulting string will be C, E, G, I, K, etc.

When the initial value is alphanumeric, for example AB3 and the increment is 4, the resulting string will be AB7, AC1, AC5, AC9, AD3, etc.

Alphabetic and numeric data values wrap when they reach the maximum allowable value for the column, starting over at 0 (numeric) or A (alphabetic). Alphabetic data includes all letters of the alphabet in upper and lower case. Integers wrap at their maximum values, for example, increment -1 wraps from -2147483648 to 2147483647, increment 1 wraps from 2147483647 to 0.

Profile Option for Repeat Specification:

ON or OFF. ON = Repeat brings up the Column Range Specification window, unless you are editing Unicode table data. See REPEAT Window for more information. OFF = Column Range Specification window is not enabled for the REPEAT command. Use the PROFILE command’s REPEAT COMMAND PROMPT option (see PROFILE-PRO) to enable the Column Range Specification window again after it is turned OFF.

Timestamp Pop-up Window

When the column data type for an incremental repeat is TIMESTAMP, you can specify the increment(s) in more detail in the following Timestamp Specification window (see the following figure). After you provide the increment information, press Enter on this screen to process the repeat and exit the window. Press END to cancel the REPEAT command and exit the window.

Important

Date and time increments always result in valid Db2 date and time values. For example, if you use a 1 month increment for a starting date of 1998/01/31, the resulting dates would be 1998/01/31, 1998/02/28, 1998/03/28, etc.

REPEAT Generate - Timestamp Specification Window

image2021-3-9_17-38-12.png

Initial value

Prefilled with the value you specified in Repeat Column Range Specification window. You are allowed to change the prefilled Initial value.

Column name

Prefilled with the value you specified in Repeat Column Range Specification window.

Month Increment

Increment to modify the month portion of the timestamp. The default increment is blank (no increment). Enter the desired month increment (1 to 99).

Day Increment

Increment to modify the day portion of the timestamp. The default increment is blank (no increment). Enter the desired day increment (1 to 999).

Year Increment

Increment to modify the year portion of the timestamp. The default increment is blank (no increment). Enter the desired year increment (1 to 9999).

Hour Increment

Increment to modify the hour portion of the timestamp. The default increment is blank (no increment). Enter the desired hour increment (1 to 99).

Minutes Increment

Increment to modify the minutes portion of the timestamp. The default increment is blank (no increment). Enter the desired minutes increment (1 to 99).

Seconds Increment

Increment to modify the seconds portion of the timestamp. The default increment is blank (no increment). Enter the desired seconds increment (1 to 99).

Microseconds Increment

Increment to modify the microseconds portion of the timestamp. The default increment is blank (no increment). Enter the desired microseconds increment (1 to 999999).

Time Pop-up Window

When the column data type for an incremental repeat is TIME, you can specify the increment(s) in more detail in the following Time Specification window (see the following figure). After you provide the increment information, press Enter on this screen to process the change and exit the window. Press END to cancel the REPEAT command and exit the window.

Important

Date and time increments always result in valid Db2 date and time values. For example, if you use a 1 month increment for a starting date of 1998/01/31, the resulting dates would be 1998/01/31, 1998/02/28, 1998/03/28, etc.

REPEAT Generate - Time Specification Window

image2021-3-9_17-39-33.png

The Time Specification window is similar to the Timestamp Specification window, however, it only includes the increment fields for hour, minutes, and seconds. See Timestamp Pop-up Window for a description of the fields.

Date Pop-up Window

When the column data type for an incremental repeat is DATE, you can specify the increment(s) in more detail in the following Date Specification window (REPEAT Generate - Date Specification Window). After you provide the increment information, press Enter on this screen to process the change and exit the window. Press END to cancel the REPEAT command and exit the window.

Important

Date and time increments always result in valid Db2 date and time values. For example, if you use a 1 month increment for a starting date of 1998/01/31, the resulting dates would be 1998/01/31, 1998/02/28, 1998/03/28, etc.

REPEAT Generate - Date Specification Window

image2021-3-9_17-40-29.png

The Date Specification window is similar to the Timestamp Specification window, however, it only includes the increment fields for month, day, and year. See Timestamp Pop-up Window for a description of the fields.

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*