The Field Name: FIELDNAME

In this section:

How to:

Reference:

Identify a field using FIELDNAME, the first attribute specified in a field declaration in the Master File. You can assign any name to a field, regardless of its name in its native data source. Likewise, for FOCUS data sources, you can assign any name to a field in a new data source.

When you generate a report, each column title in the report has the name of the field displayed in that column as its default, so assigning meaningful field names helps readers of the report. Alternatively, you can specify a different column title within a given report by using the AS phrase in the report request, as described in the Creating Reports With WebFOCUS Language manual, or a different default column title for all reports by using the TITLE attribute in the Master File, as described in Alternative Report Column Titles: TITLE.


Top of page

x
Syntax: How to Identify the Field Name
FIELD[NAME] = field_name

where:

field_name

Is the name you are giving this field. It can be a maximum of 66 characters. Some restrictions apply to names longer than 12 characters, as described below. The name can include any combination of letters, digits, and underscores (_), and must contain at least one letter. Other characters are not recommended, and may cause problems in some operating environments or when resolving expressions.

It is recommended that you not use field names of the type Cn, En, and Xn (where n is any sequence of one or two digits) because these can be used to refer to report columns, HOLD file fields, and other special objects.

If you must use special characters because of a field report column title, consider using the TITLE attribute in the Master File to specify the title, as described in Alternative Report Column Titles: TITLE.


Top of page

x
Reference: Usage Notes for FIELDNAME

Note the following rules when using FIELDNAME:

  • Alias. FIELDNAME has an alias of FIELD.
  • Changes. In a FOCUS data source, if the INDEX attribute has been set to I (that is, if an index has been created for the field), you cannot change the field name without rebuilding the data source. You may change the name in all other situations.


x
Using a Long and Qualified Field Name

How to:

Reference:

In Master Files, field names and aliases can have a maximum length of 66 characters. However, before defining a field name longer than 48 characters, you must consider how the name will be referenced in requests.

Requests can qualify all referenced field names and aliases with file and/or segment names, a useful technique when duplicate field names exist across segments in a Master File or in joined data sources. But, although the qualifiers and qualification characters are valid only in requests, not in Master Files, the 66-character maximum includes any qualifiers and qualification characters used with the field name in requests. Therefore, if you define a 66-character name in the Master File, you cannot use qualifiers with the name in a request.

The maximum of 66 characters includes the name of the field or alias, plus each field qualifier (Master File name and segment name), plus a qualification character (usually a period) for each qualifier. You may use a unique truncation of a 66-character name with a qualifier.

Temporary field names may also contain up to 66 characters. The names of text fields and indexed fields in FOCUS Master Files are limited to 12 characters. Text fields and indexed fields in XFOCUS Master Files are not subject to this 12 character limitation. However, the aliases for text and indexed fields may be up to 66 characters. Field names up to 66 characters appear as column titles in TABLE reports if there is no TITLE attribute or AS phrase.

The default value for the SET FIELDNAME command, SET FIELDNAME=NEW, activates long and qualified field names. The syntax is described in the Developing Reporting Applications manual.



x
Syntax: How to Specify a Qualified Field Name in a Request
[filename.][segname.]fieldname

where:

filename

Is the name of the Master File or tag name. Tag names are used with the JOIN and COMBINE commands.

segname

Is the name of the segment in which the field resides.

fieldname

Is the name of the field.



Example: Qualifying a Field Name

The fully qualified name of the field EMP_ID in the EMPINFO segment of the EMPLOYEE data source is:

EMPLOYEE.EMPINFO.EMP_ID


x
Syntax: How to Change the Qualifying Character
SET QUALCHAR = qualcharacter

The period (.) is the default qualifying character. For further information about the SET QUALCHAR command and valid qualifying characters (. : ! % | \ ), see the Developing Reporting Applications manual.



x
Reference: Restrictions for Long and Qualified Field Names

The following restrictions apply to field names and aliases longer than 12 characters (that is, long names):

  • You cannot use a long name to specify a join:
    • In a JOIN command, for a cross-referenced field in a FOCUS data source.
    • In a multi-table Master File for a relational data source, for the KEYFLD and IXFLD attributes in the Access File.
  • Indexed fields and text fields in FOCUS data sources cannot have field names longer than 12 characters. Indexed fields and text fields in XFOCUS data sources are not subject to this 12 character limitation. Long ALIAS names are supported for both types of data sources.
  • The SQL Translator supports field names of up to 48 characters.
  • A field name specified in an alternate file view cannot be long or qualified.
  • The CHECK FILE command PICTURE and HOLD options display the first 11 characters of long names within the resulting diagram or HOLD file. A caret (>) in the 12th position indicates that the name is longer than the displayed portion.
  • ?FF, ? HOLD, ? DEFINE

    These display up to 31 characters of the name, and display a caret (>) in the 32nd character to indicate a longer field name.



x
Using a Duplicate Field Name

Field names are considered duplicates when you can reference two or more fields with the same field name or alias. Duplication may occur:

  • If a name appears multiple times within a Master File.
  • In a JOIN between two or more Master Files, or in a recursive JOIN.
  • If you issue a COMBINE and do not specify a prefix.

Duplicate fields (those having the same field name and alias) are not allowed in the same segment. The second occurrence is never accessed, and the following message is generated when you issue CHECK and CREATE FILE:

(FOC1829) WARNING. FIELDNAME IS NOT UNIQUE WITHIN A SEGMENT: fieldname

Duplicate field names may exist across segments in a Master File. To retrieve such a field, you must qualify its name with the segment name in a request. If a field that appears multiple times in a Master File is not qualified in a request, the first field encountered in the Master File is the one retrieved.

Note: If a Master File includes duplicate field names for real fields and/or virtual fields, the following logic is used when retrieving a field:

  • If only virtual fields are duplicated, the last virtual field is retrieved.
  • If only real fields are duplicated, the first real field is retrieved.
  • If a Master File has both a real field and one or more virtual fields with the same name, the last virtual field is retrieved.
  • If a field defined outside of a Master File has the same name as a virtual or real field in a Master File, the last field defined outside of the Master File is retrieved.

Reports can include qualified names as column titles. The SET QUALTITLES command, discussed in the Developing Reporting Applications manual, determines whether reports display qualified column titles for duplicate field names. With SET QUALTITLES=ON, they display qualified column titles for duplicate field names even when the request itself does not specify qualified names. The default value, OFF, disables qualified column titles.



x
Rules for Evaluating a Qualified Field Name

The following rules are used to evaluate qualified field names:

  • The maximum field name qualification is filename.segname.fieldname. For example:
    TABLE FILE EMPLOYEE 
    PRINT EMPLOYEE.EMPINFO.EMP_ID 
    END

    includes EMP_ID as a fully qualified field. The file name, EMPLOYEE, and the segment name, EMPINFO, are the field qualifiers.

    Qualifier names can also be duplicated. For example:

    FILENAME=CAR, SUFFIX=FOC 
      SEGNAME=ORIGIN, SEGTYPE=S1 
          FIELDNAME=COUNTRY, COUNTRY, A10, $    
      SEGNAME=COMP, SEGTYPE=S1, PARENT=ORIGIN 
          FIELDNAME=CAR, CARS, A16, $  
            .   
            . 
            .  
    TABLE FILE CAR 
    PRINT CAR.COMP.CAR 
    END

    This request prints the field with alias CARS. Both the file name and field name are CAR.

    A field name can be qualified with a single qualifier, either its file name or its segment name. For example:

    FILENAME=CAR, SUFFIX=FOC 
       SEGNAME=ORIGIN, SEGTYPE=S1 
          FIELDNAME=COUNTRY, COUNTRY, A10, $ 
       SEGNAME=COMP, SEGTYPE=S1, PARENT=ORIGIN 
          FIELDNAME=CAR, CARS, A16, $  
            . 
            . 
            .  
    TABLE FILE CAR 
    PRINT COMP.CAR AND CAR.CAR 
    END

    This request prints the field with alias CARS twice.

    When there is a single qualifier, segment name takes precedence over file name. Therefore, if the file name and segment name are the same, the field qualified by the segment name is retrieved.

  • If a field name begins with characters that are the same as the name of a prefix operator, it may be unclear whether a request is referencing that field name or a second field name prefixed with the operator. The value of the first field is retrieved, not the value calculated by applying the prefix operator to the second field. In the next example, there is a field whose unqualified field name is CNT.COUNTRY and another whose field name is COUNTRY:
    FILENAME=CAR, SUFFIX=FOC 
       SEGNAME=ORIGIN, SEGTYPE=S1 
          FIELDNAME=CNT.COUNTRY, ACNTRY, A10, $ 
          FIELDNAME=COUNTRY, BCNTRY, A10, $ 
    TABLE FILE CAR 
    SUM CNT.COUNTRY 
    END

    In this request, the string CNT.COUNTRY is interpreted as a reference to the field named CNT.COUNTRY, not as a reference to the prefix operator CNT. applied to the field named COUNTRY. Therefore, the request sums the field whose alias is ACNTRY. Although the field name CNT.COUNTRY contains a period as one of its characters, it is an unqualified field name. It is not a qualified name or a prefix operator acting on a field name, neither of which is allowed in a Master File. The request does not count instances of the field whose alias is BCNTRY.

  • If a Master File has either a file name or segment name that is the same as a prefix operator, the value of the field within the segment is retrieved in requests, not the value calculated by applying the prefix operator to the field.

    For example:

    FILENAME=CAR, SUFFIX=FOC 
       SEGNAME=ORIGIN, SEGTYPE=S1 
          FIELDNAME=COUNTRY, COUNTRY, A10, $ 
       SEGNAME=PCT, SEGTYPE=S1, PARENT=ORIGIN 
          FIELDNAME=CAR, CARS, I2, $ 
     TABLE FILE CAR 
    SUM PCT.CAR PCT.PCT.CAR 
    BY COUNTRY 
    END

    This request sums the field with alias CARS first, and then the percent of CARS by COUNTRY.

  • When a qualified field name can be evaluated as a choice between two levels of qualification, the field name with the higher level of qualification takes precedence.

    In the following example, the choice is between an unqualified field name (the field named ORIGIN.COUNTRY in the ORIGIN segment) and a field name with segment name qualification (the field named COUNTRY in the ORIGIN segment). The field with segment name qualification is retrieved:

    FILENAME=CAR, SUFFIX=FOC 
       SEGNAME=ORIGIN, SEGTYPE=S1 
          FIELDNAME=ORIGIN.COUNTRY, OCNTRY, A10, $ 
          FIELDNAME=COUNTRY, CNTRY, A10, $ 
    TABLE FILE CAR 
    PRINT ORIGIN.COUNTRY 
    END

    This request prints the field with alias CNTRY. To retrieve the field with alias OCNTRY, qualify its field name, ORIGIN.COUNTRY, with its segment name, ORIGIN:

    PRINT ORIGIN.ORIGIN.COUNTRY
  • When a qualified field name can be evaluated as a choice between two field names with the same level of qualification, the field with the shortest basic field name length is retrieved. For example:
    FILENAME=CAR, SUFFIX=FOC
       SEGNAME=CAR, SEGTYPE=S1
          FIELDNAME=CAR.CAR, CAR1, A10, $
       SEGNAME=CAR.CAR, SEGTYPE=S1, PARENT=CAR
          FIELDNAME=CAR, CAR2, A10, $
    TABLE FILE CAR
    PRINT CAR.CAR.CAR
    END

    In this example, it is unclear if you intend CAR.CAR.CAR to refer to the field named CAR.CAR in the CAR segment, or the field named CAR in the CAR.CAR segment. (In either case, the name CAR.CAR is an unqualified name that contains a period, not a qualified name. Qualified names are not permitted in Master Files.)

    No matter what the intention, the qualified field name is exactly the same and there is no obvious choice between levels of qualification.

    Since the field with alias CAR2 has the shortest basic field name length, CAR2 is printed. This is different from the prior example, where the choice is between two levels of qualification. To retrieve the CAR1 field, you must specify its alias.


WebFOCUS