CHANGE primary command

In a File Manager/Db2 editor session, use the CHANGE command to locate and replace one or more occurrences of a character string or numeric value in the data being edited.
Note: If you limit the number of rows loaded into the FM/Db2 editor (by either specifying a row limit or a WHERE clause), the CHANGE command applies only to the data in the FM/Db2 editor session.

To find a string without changing it, use the FIND primary command.

If you have zoomed in on a row, the CHANGE command affects only that row.

If the CHANGE command changes data, FM/Db2 places the cursor at the end (when scanning forward), or start (when scanning backwards), of the changed string or numeric data type column. If necessary, FM/Db2 scrolls to bring the string into view. If the changed data is in an excluded row, the excluded row is displayed.

Syntax


1 Change
1 CX
1 CHG(1)
string details

1 *
1 from_string
1 *
1 to_string
1! NEXT
1 ALL
1 PREV
1 LAST
1 FIRST
1! CHARs
1 PREfix
1 SUFfix
1 WORD
1 X
1 EX
1 NX
column list or range

1 ! #ALL
2.1 (+ , col_num)
1 (+ , col_num_1 - col_num_2)
Notes:
  • 1 You can specify parameters in any order.
* (asterisk)
When used in place of the search string, uses the search string specified on the previous CHANGE command as the search string.

When used in place of the replacement string, uses the replacement string specified on the previous CHANGE command as the replacement string.

The position of the * is important for CHANGE. If it is positioned before a string, it indicates the previous search argument; that is, it is treated as the first string. If a string is found prior to the *, then it is treated as the second string (the change argument), taking the change argument from the previous CHANGE command. To use both the previous search string and the previous change string, specify CHANGE * *.

from_string
The string you want to search for. The string, which can be up to 100 characters in length, can be:
  • A character string not starting or ending with a single quotation mark and not containing any embedded blanks or commas. The case of the string is ignored. Uppercase and lowercase representations of the same character match. For example, the following command changes the strings black, Black, and BLACK:
    CHANGE black white
  • A character string enclosed in single quotation marks. The string can contain blanks and commas. The case of the string is ignored. For example, 'Exact string' matches 'exact string'.
  • C followed by a character string enclosed in quotation marks (C'Frog'), or a character string enclosed in quotation marks followed by C ('Frog'C). The string can contain blanks and commas. The string must match exactly (including case). For example, C'Exact string' does not match C'exact string'.
  • P preceded or followed by a picture string enclosed in single or double quotation marks to describe a type of string to be found rather than the exact characters. It can contain blanks, alphabetic and numeric characters which represent themselves, or any of the special characters listed here, each of which represents a class of characters:
    =
    Any character.
    @
    Alphabetic characters.
    #
    Numeric characters.
    $
    Special characters.
    & notsym;
    Non-blank characters.
    .
    Invalid characters.
    -
    Non-numeric characters.
    <
    Lowercase alphabetics.
    >
    Uppercase alphabetics.
  • X followed by a hexadecimal string enclosed in single quotation marks (X'C1C2').
  • A numeric value (only when you limit the search by specifying column numbers, and only when the column being searched is a numeric column).
to_string
The string you want to replace from_string. The string, which can be up to 100 characters in length, can be:
  • A character string not starting or ending with a single quotation mark and not containing any embedded blanks or commas. If CAPS ON or CASE UPPER is in effect, then to_string is converted to uppercase.
  • A character string enclosed in single quotation marks. The string can contain blanks and commas. If CAPS ON or CASE UPPER is in effect, then to_string is converted to uppercase. The string can be a null string ('').
  • C followed by a character string enclosed in quotation marks (C'Frog'), or a character string enclosed in quotation marks followed by C ('Frog'C). The string can contain blanks and commas. Case is respected and retained. The string can be a null string (C'').
  • P preceded or followed by a picture string enclosed in single or double quotation marks to describe the change to be made. You can change characters from uppercase to lowercase or from lowercase to uppercase, or leave the field the same using these string special characters.
    =
    Any character.
    <
    Lowercase alphabetics.
    >
    Uppercase alphabetics.

    Examples of picture strings used with the CHANGE command:

    c p'<' p'>' #3
    Uppercase characters in column 3.
    c p'>' '¬' #2
    Change any uppercase to "not sign" column 2 (note: "not sign" has no special meaning in a "to" string).
    c p'<#' p'>=' #1
    Change any lowercase, any number to uppercase, the number found in column 1.

    When this notation is used, numeric, bit and unicode fields (for SNGL and TABL display formats) are excluded from the search process.

    .
  • X followed by a hexadecimal string enclosed in single quotation marks (X'C1C2'). Case is respected and retained (the hexadecimal values are used exactly as specified).
  • A numeric value.
NEXT
This is the default setting. Causes the search to begin at the cursor location (if the cursor is within the data portion of the display) or the beginning of the first row displayed, and searches ahead to find the next occurrence of the string. If the next occurrence of the string is in an excluded row and you do not limit the search to non-excluded rows, only the first excluded row containing the string is shown.
ALL
Causes the search to begin at the top of the data and find and replace all occurrences of the string. If you do not limit the search to non-excluded rows, the string is replaced in all rows (excluded and non-excluded). Any excluded rows affected by the change are redisplayed.
FIRST
Causes the search to begin at the beginning of the table and search ahead.
LAST
Causes the search to begin at the end of the table and search backwards.
PREV
Causes the search to begin at the cursor location (if the cursor is within the data portion of the display) or the beginning of the first row displayed, and searches backwards to find the string.
CHARS
Matches the search string anywhere in the data.
PREFIX
Matches the search string wherever it appears as a prefix in the data. To be a prefix, the matched text must be preceded by a non-alphanumeric character or be the start of a line or field, and must be followed by an alphanumeric character.
SUFFIX
Matches the search string wherever it appears as a suffix in the data. To be a suffix, the matched text must be preceded by an alphanumeric character, and must be followed by a non-alphanumeric character or be the end of a line or field.
WORD
Matches the search string wherever it appears as a word in the data. To be a word, the matched text must be preceded by a non-alphanumeric character or be the start of a line or field, and must be followed by a non-alphanumeric character or be the end of a line or field.
#ALL
Each column is searched according to its template attributes.
col_num
The Db2® column number (specified as #n) of a column to be included in the data search. Multiple column numbers must be separated by a comma or, if enclosed in brackets, separated by a blank or comma.
col_num_1
The first field reference of a range of fields. It cannot be subscripted. If the col_num_1 field reference value is less than the lowest displayed field reference value, the lowest displayed field reference value is used.
col_num_2
The last field reference of a range of fields. It cannot be subscripted. If the col_num_2 field reference value is greater than the highest displayed field reference value, the highest displayed field reference value is used.

The col_num_1 and col_num_2 field reference values must be separated by a hyphen (-). Spaces are permitted between the hyphen and the field reference values.

If col_num_1 is a higher value than col_num_2, the search process reverses the operands.

label1
Label identifying the start of a range of rows. The label must start with a period (.) followed by one to four alphabetic characters (no numeric or special characters). Labels starting with the letter “Z” indicate an editor-assigned label.
label2
Label identifying the end of a range of rows. The label must start with a period (.) followed by one to four alphabetic characters (no numeric or special characters). Labels starting with the letter “Z” indicate an editor-assigned label.
EX
Excluded rows only.
NX
Non-excluded rows only.
X
Same as EX.

Availability

Related tasks