Example 1
The following example expands the POSTAL_CODE field to nine
characters and adds DATATRIEVE support characteristics:
RDO> INVOKE DATABASE FILENAME 'MF_PERSONNEL'
RDO> SHOW FIELDS POSTAL_CODE
POSTAL_CODE text size is 5
Description: Postal code (in US = ZIP)
RDO> CHANGE FIELD POSTAL_CODE
cont> DATATYPE IS TEXT SIZE IS 9 CHARACTERS
cont> DEFAULT_VALUE FOR DTR IS "000000000"
cont> EDIT_STRING FOR DTR IS "XXXXX-XXXX".
RDO> SHOW FIELD POSTAL_CODE
POSTAL_CODE text size is 9
Description: Postal code (in US = ZIP)
Edit string: XXXXX-XXXX
Default value: "000000000"
RDO> FOR E IN EMPLOYEES
cont> PRINT E.POSTAL_CODE
cont> END_FOR
03817
03817
03301
03456
.
.
.
03301
03809
RDO> STORE E IN EMPLOYEES USING
cont> E.LAST_NAME = "Forester";
cont> E.EMPLOYEE_ID = "00876";
cont> E.POSTAL_CODE = "039875573"
cont> END_STORE
RDO> FOR E IN EMPLOYEES
cont> WITH E.LAST_NAME = "Forester" OR
cont> E.LAST_NAME = "Toliver"
cont> PRINT
cont> E.EMPLOYEE_ID,
cont> E.POSTAL_CODE
cont> END_FOR
00164 03817
00876 039875573
The field remains a text field, but the length is increased
to nine characters, and an edit string and default value are
specified for DATATRIEVE. When you display the data, existing
field values are padded on the right with spaces. Thus an
existing postal code would appear as "03104 ". Newly stored
values can have nine characters.
Example 2
The accounting department has decided that the BUDGET field will
now include pennies:
RDO> SHOW FIELDS BUDGET
BUDGET signed longword scale 0
Description: Generic budget data
Edit string: $$$,$$$,$$$
RDO> FOR D IN DEPARTMENTS
cont> WITH D.DEPARTMENT_NAME = 'Manufacturing'
cont> PRINT D.BUDGET_ACTUAL
cont> END_FOR
BUDGET_ACTUAL
0
RDO> CHANGE FIELD BUDGET
cont> DATATYPE IS SIGNED LONGWORD SCALE -2
cont> EDIT_STRING FOR DTR IS "$$$$,$$9.99".
RDO> SHOW FIELDS BUDGET
BUDGET signed longword scale -2
Description: Generic budget data
Edit string: $$$$,$$9.99
RDO> FOR D IN DEPARTMENTS
cont> WITH D.DEPARTMENT_NAME = 'Manufacturing'
cont> PRINT D.BUDGET_ACTUAL
cont> END_FOR
BUDGET_ACTUAL
0.00
Example 3
You can add or change a VALID IF clause for a field. However, if
the database contains any data that violates the specification
of the VALID IF clause, the clause is rejected. The following
example shows two CHANGE FIELD... VALID IF statements. In the
first instance, the specification is rejected because existing
records contain EMPLOYEE_ID values less than "98765"; in the
second instance, the specification is accepted.
RDO> CHANGE FIELD ID_NUMBER VALID IF ID_NUMBER > "98765".
%RDB-E-NO_META_UPDATE, metadata update failed
-RDMS-E-NOT_VALID_FR, field ID in relation CURRENT_INFO fails validation
RDO> CHANGE FIELD ID_NUMBER VALID IF ID_NUMBER > "00050".
RDO> SHOW FIELD ID_NUMBER
ID_NUMBER text size is 5
Description: Generic employee ID
Missing value:
Valid: IF ID_NUMBER > "00050"