Managing fields manually: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
No edit summary
Line 1: Line 1:
==Overview==
==Overview==
<p>This chapter describes the REDEFINE, DELETE, and RENAME commands, which allow you to redefine many field attributes, to delete a field's description and all its occurrences in the data, and to rename fields. For the complete syntax and description of the commands, see the <var class="product">Model&nbsp;204</var> Parameter and Command Reference.</p>
<p>This chapter describes the [[REDEFINE command|REDEFINE]], [[DELETE command: Field|DELETE]], and [[RENAME FIELD command|RENAME]] commands, which allow you to redefine many field attributes, to delete a field's description and all its occurrences in the data, and to rename fields. For the complete syntax and description of these commands, please follow the links.</p>
<p>'''Note''' that, new fields and Repeating Field Groups may may be added by the file manager at any time (although some attributes may not be assigned to these new fields (such as the [[#Field Design (File Management)#Preallocated Fields|OCCurs attribute]] to preallocate a field) once data has been added to the file. See [[Field Design (File Management)|Field Design]] for more details.</p>  
 
<p>After creating a file and adding fields, you can perform the following field management tasks:</p>
<p>After creating a file and adding fields, you can perform the following field management tasks:</p>
<ul>
<ul>
Line 9: Line 11:
<li>Reclaiming space in files</li>
<li>Reclaiming space in files</li>
</ul>
</ul>
<p>The operative word is 'can', which does not always mean that you should. If you have a large file, and are performing actions which cause Table B to be read in its entirety (the DELETE of a number of fields, or REDEFINING fields to be indexed for example) you should consider whether it may be more efficient to [[File Reorganization and Table Compaction|reorganize]] the file.</p> 
==Redefining fields==
==Redefining fields==
<p>The REDEFINE command and the IFRFLD Host Language Interface function allow you to alter a field definition without requiring that the file be reinitialized.</p>
<p>The REDEFINE command and the IFRFLD Host Language Interface function allow you to alter a field definition without requiring that the file be reinitialized.</p>
<p class="note"><b>Exception:</b> In order to redefine fields that have the OCCURS attribute, you must reinitialize the file.</p>
<p class="note"><b>that exceptions are noted below.</p>
<p>The format of REDEFINE is:</p>
<p>The format of REDEFINE is:</p>
<b>Syntax</b>
<b>Syntax</b>
Line 146: Line 152:
<p class="note"><b>Note:</b> Redefining fields will take a substantial amount of CPU time. When a KEY, NUMERIC RANGE, or ORDERED attribute is changed for a VISIBLE field, <var class="product">Model&nbsp;204</var> must modify the index entries that correspond to each occurrence of the field in Table B.  </p>
<p class="note"><b>Note:</b> Redefining fields will take a substantial amount of CPU time. When a KEY, NUMERIC RANGE, or ORDERED attribute is changed for a VISIBLE field, <var class="product">Model&nbsp;204</var> must modify the index entries that correspond to each occurrence of the field in Table B.  </p>
<p>When a field is redefined to add an indexed attribute, every record containing that field will have its index entry in Table C or D updated.</p>
<p>When a field is redefined to add an indexed attribute, every record containing that field will have its index entry in Table C or D updated.</p>
===Restrictions:===
<p>Fields may not be redefined to or from [[#Field Design (File Management)#Preallocated Fields|OCCurs]].</p>
<p>Fields may not be redefined in to or out of a [[#Field Design (File Management)#FIELDGROUP attribute|Repeating Field Group]].</p>
<p>Fields may not be redefined to or from [[#Field Design (File Management)#BLOB CLOB or MINLOBE attributes|a large object]].</p>
<p>For any of these situations, the file must be reinitialized.</p>
<p>In addition:</p>
===Redefining UNIQUE fields===
===Redefining UNIQUE fields===
<p>UNIQUE fields must be ORDERED. A field can be redefined as UNIQUE only if there are no nonunique values for that field in the file. </p>
<p>UNIQUE fields must be ORDERED. A field can be redefined as UNIQUE only if there are no nonunique values for that field in the file. </p>
Line 158: Line 175:
===Redefining fields with security levels===
===Redefining fields with security levels===
<p>If a field that is being redefined has a security level defined for it (see <b>See</b>), you must have a field security level that permits some type of access.</p>
<p>If a field that is being redefined has a security level defined for it (see <b>See</b>), you must have a field security level that permits some type of access.</p>
==Deleting fields==
==Deleting fields==
<p>Use the DELETE FIELD command and the IFDELF Host Language Interface function to delete a field definition and all occurrences of data and indices for that field for every record in the file. The command is issued in the form: </p>
<p>Use the DELETE FIELD command and the IFDELF Host Language Interface function to delete a field definition and all occurrences of data and indices for that field for every record in the file. The command is issued in the form: </p>
Line 165: Line 183:
<p>where:</p>
<p>where:</p>
<p>fieldname is the name assigned when the field was defined. </p>
<p>fieldname is the name assigned when the field was defined. </p>
<p>A DELETE FIELD command cannot be used to delete record security fields or sort and hash key fields. If the field being deleted is in a file that has record security, you must have record security override privileges (see <b>See Record security</b>). If the field has a security level defined for it, you must have a field-level security level that permits update access.</p>
<p>A DELETE FIELD command cannot be used to delete record security fields or sort and hash key fields. If the field being deleted is in a file that has record security, you must have record security override privileges (see <b>See [[#Security#Record security|record security]] </b>). If the field has a security level defined for it, you must have a field-level security level that permits update access.</p>
<p>Other uses of the DELETE command are discussed in the <var class="product">Model&nbsp;204</var> Parameter and Command Reference. </p>
<p>Other uses of the DELETE command are discussed in the [[:Category:Commands|Commands category]], specifically:</p>
* [[DELETE command: Procedure|procedures]]
* [[DELETE command: Permanent group|permanent groups]]
* [[DELETE command: Temporary group|temporary groups]]
 
<b>DELETE FIELD with date-time stamp fields</b>
<b>DELETE FIELD with date-time stamp fields</b>
<p>The DELETE FIELD command is prohibited for the DTSFN field in a file when the FOPT=X'10' is set.</p>
<p>The DELETE FIELD command is prohibited for the DTSFN field in a file when the FOPT=X'10' is set.</p>
Line 184: Line 206:
<p>&nbsp;</p>
<p>&nbsp;</p>
[[Category:File manager]]
[[Category:File manager]]
[[Category:File management]]

Revision as of 21:54, 24 April 2013

Overview

This chapter describes the REDEFINE, DELETE, and RENAME commands, which allow you to redefine many field attributes, to delete a field's description and all its occurrences in the data, and to rename fields. For the complete syntax and description of these commands, please follow the links.

Note that, new fields and Repeating Field Groups may may be added by the file manager at any time (although some attributes may not be assigned to these new fields (such as the OCCurs attribute to preallocate a field) once data has been added to the file. See Field Design for more details.

After creating a file and adding fields, you can perform the following field management tasks:

  • Redefine fields
  • Monitor field retrievals
  • Deleting fields
  • Renaming fields
  • Reclaiming space in files

The operative word is 'can', which does not always mean that you should. If you have a large file, and are performing actions which cause Table B to be read in its entirety (the DELETE of a number of fields, or REDEFINING fields to be indexed for example) you should consider whether it may be more efficient to reorganize the file.


Redefining fields

The REDEFINE command and the IFRFLD Host Language Interface function allow you to alter a field definition without requiring that the file be reinitialized.

that exceptions are noted below.

The format of REDEFINE is:

Syntax

REDEFINE [FIELD] {field_desc [field_desc ...] | fieldname WITH attribute [attribute ...]}

where:

field_desc takes the form:

fieldname [(attribute [,[attribute ...]])]

  • fieldname is the name of a field in the open Model 204 file.
  • attribute is one of the attributes listed in Redefining fields. In the REDEFINE command, you need to specify only the attributes being changed for the field.

Example

The following command changes two attributes of the previously defined CUSTID field:

Before:

DEFINE FIELD CUSTID WITH FRV KEY

After:

REDEFINE FIELD CUSTID WITH NON-FRV NON-KEY ORDERED CHAR

Not all the field attributes that can be specified in the DEFINE command can be changed by a REDEFINE command. Redefining fields summarizes the supported options.

Field attributes with the REDEFINE command
Field description attribute Abbreviation

KEY

NON-KEY

-

NKEY

[NUMERIC] RANGE

NON-RANGE

NR

NNR

ORDERED

NON-ORDERED

ORD

NORD

FRV

NON-FRV

-

NFRV

DEFERRABLE

NON-DEFERRABLE

DEF

NDEF

FEW-VALUED

MANY-VALUED

FV

MV

UPDATE IN PLACE

UPDATE AT END

UP

UE

LEVEL k LVL k

UNIQUE

NON-UNIQUE

UNIQ

NUNIQ

Field attributes are introduced in Field Descriptions and Attributes .

Changing a field's security level to 0 desecures the field. Refer to See Field-level security for more information.

Note: Redefining fields will take a substantial amount of CPU time. When a KEY, NUMERIC RANGE, or ORDERED attribute is changed for a VISIBLE field, Model 204 must modify the index entries that correspond to each occurrence of the field in Table B.

When a field is redefined to add an indexed attribute, every record containing that field will have its index entry in Table C or D updated.

Restrictions:

Fields may not be redefined to or from OCCurs.

Fields may not be redefined in to or out of a Repeating Field Group.

Fields may not be redefined to or from a large object.

For any of these situations, the file must be reinitialized.

In addition:

Redefining UNIQUE fields

UNIQUE fields must be ORDERED. A field can be redefined as UNIQUE only if there are no nonunique values for that field in the file.

Redefining KEY, NUMERIC RANGE, ORDERED, or FRV fields

Model 204 adds entries to the index when the KEY, NUMERIC RANGE, ORDERED, or FRV fields are redefined. If the index fills up, Model 204 displays an error message and the redefine fails. If TBO is enabed, the field is restored to its original status. If TBO is disabled (FOPT=x'02') and the redefine fails, the file will be broken.

Redefining INVISIBLE fields

If an INVISIBLE field is redefined to change or add an indexing attribute, such as KEY, ORD CHAR, or ORD NUM, only values of the field added to the file after the redefinition are recorded in the index. Values of the field existing before the redefinition cannot be generated into the indexes.

You cannot use the REDEFINE command to add a new index to a field with the INVISIBLE attribute that is in a file that has been used, so that MSTRADD statistic value parameter is set to nonzero. For an invisible field the REDEFINE command cannot specify the KEY, ORD CHAR, and ORD NUM attribute nor the NUMERIC RANGE attribute, unless the field was originally defined with that attribute.

If an INVISIBLE field is redefined to be FRV, only values of the field added to the file after the redefinition are recorded in Table A. Values of the field existing before the redefinition cannot be generated into Table A.

Redefining NUMERIC RANGE fields

Model 204 does not allow fields that have the NUMERIC RANGE attribute to occur more than once in a record, and it does not permit the addition of subsequent occurrences to a record for NUMERIC RANGE fields. If a field is redefined to NUMERIC RANGE and Model 204 detects that it is multiply occurring, any redefinition stops. If TBO is enabed, the field is restored to its original status. If TBO is disabled (FOPT=x'02') and the redefine fails, the file will be broken.

Redefining fields with security levels

If a field that is being redefined has a security level defined for it (see See), you must have a field security level that permits some type of access.

Deleting fields

Use the DELETE FIELD command and the IFDELF Host Language Interface function to delete a field definition and all occurrences of data and indices for that field for every record in the file. The command is issued in the form:

Syntax

DELETE FIELD fieldname

where:

fieldname is the name assigned when the field was defined.

A DELETE FIELD command cannot be used to delete record security fields or sort and hash key fields. If the field being deleted is in a file that has record security, you must have record security override privileges (see See record security ). If the field has a security level defined for it, you must have a field-level security level that permits update access.

Other uses of the DELETE command are discussed in the Commands category, specifically:

DELETE FIELD with date-time stamp fields

The DELETE FIELD command is prohibited for the DTSFN field in a file when the FOPT=X'10' is set.

Renaming fields

The RENAME command and the IFNFLD Host Language Interface function allow you to rename a field. The command is issued in the form:

Syntax

RENAME FIELD oldname,newname

where:

oldname is the current name of the field.

newname is the name that you want to assign.

This command is not executed if the old field name does not exist or if the new name cannot be added to the internal file dictionary, either because it already exists or because there is not enough space.

Note

If a TABLE C FULL condition occurs during the renaming of a KEY or NUMERIC RANGE field, the file is left in a broken state. This happens even if the file is a transaction back out file. To prevent this condition, issue a TABLEC command to check for available space and/or back up the file before renaming a field.

Record security fields and sort and hash key fields can be renamed. If a field that is being renamed has a security level defined for it (see See Field-level security"), you must have a field security level that permits some type of access.

The RENAME command cannot be used to rename an INVISIBLE field. If you do want to rename an INVISIBLE field, delete all occurrences of the old field and then add them to the record under the new name.