Modify field types: Character (scalar) to array

Applies to User Roles:

System Administrator

Example: Change a field with existing data, called address, from a character type scalar field to an array. For this example, assume that we created a new file called vendorview from the format vendor.

To modify field types, character (scalar) to array:

  1. Select the address field name. Only one entry for address should appear, as it is currently a scalar field.
  2. Click Edit.
  3. In the Name field, type: old.address.
  4. Leave the Type field value as character.
  5. Click OK to close the window and commit the change to the file.
    The address field name is now old.address in the Field Name array.
  6. Select the descriptor structure, and then click New.
  7. In the Name field, type: address.
  8. In the Type field, type:array.
  9. Click Add to commit the new array to the file.
    When adding an array field, you also need to specify the type of array (for example, character, number, date/time, etc.). Service Manager prompts you for this information now.
    A new field.window opens with address displayed in the Name field and the Type field blank. The message Enter data type of array’s element also appears at the bottom of the format window.
  10. Select the Type field and type:character.
  11. Click Add.
    Notice two entries for address now exist in the database dictionary record since it has been defined as a character array.
  12. Click OK to close the window and save the changes.
  13. Click OK to end this session with the vendorview file.

The field type has been changed, but this is not the end of the process.

Because data exists in the file, you need to move the contents of the field now called old.address to the field called address. To accomplish this, perform a Mass Update in Database Manager on all records in the file that have data in the old.address field.

Once the data has been moved, we recommend that you also remove the old.address field from the database dictionary record.

The Mass Update instruction string to move the data from the field called old.address to the first element in the newly created array called address is:

1 in address in $file = old.address in $file

Related topics

Fields within structures
Methods for adding database dictionary records
Methods for updating database dictionary records
Methods for deleting database dictionary records
Arrays
Structures
Arrayed structures
Alias fields
Adding a key
Modifying a key
Deleting a key

Access the Database Dictionary utility
Add fields to a structure
Modify field types: Single to concatenated
Open a database dictionary
Regen a database dictionary
Search for a field in the database dictionary