TOCPREVNEXTINDEX

AcuODBC User's Guide
Version 6.0

6.3.7 NAME Directive

The NAME directive assigns a database field name to the data item defined on the next line. You can use the NAME directive to prevent duplicate field names.

Syntax

    $XFD NAME=fieldname   

or

    *(( XFD NAME=fieldname ))   

This directive has several uses, as shown in the following examples.

Example 1 - duplicate names for data items in a single record

Within AcuODBC's "virtual" database file, all field names must be unique. (Multiple database tables may include the same field name, but duplicates may not exist within a single table.) Unique field names are not required in COBOL, because names can be qualified by group items. For example, this is acceptable in COBOL:

                   10  last_visit.   
                       15  mm                  pic 99.   
                       15  dd                  pic 99.   
                       15  yy                  pic 99.   
                   10  last_payment.     
                       15  mm                  pic 99.   
                       15  dd                  pic 99.   
                       15  yy                  pic 99.   

It is not, however, acceptable for a database to have a table with two columns with the same name. In fact, you will not be able to compile and generate a data dictionary with this source code in your program.

You need not change the field names in your COBOL program to make them accessible to your Windows application through ODBC. Instead, you use the NAME directive to provide unique names for the fields.

Although this is not included in the sample code, here is an example of using the NAME directive when you have duplicate field names:

                   10  last_visit.   
                       15  mm                  pic 99.   
                       15  dd                  pic 99.   
                       15  yy                  pic 99.   
                   10  last_payment.     
          $XFD NAME=MONTH_PD             
                       15  mm                  pic 99.   
          $XFD NAME=DAY_PD   
                       15  dd                  pic 99.   
          $XFD NAME=YEAR_PD   
                       15  yy                  pic 99.   

The "dates" portion of the "virtual" database table will look like this:

mm
dd
yy
MONTH_PD
DAY_PD
YEAR_PD
06
18
02
07
04
02

Example 2 - assigning shorter names

You may want to use the NAME directive to assign shorter names than those used in your COBOL programs. This makes the formation of interactive SQL queries easier and quicker. For example:

           FILE SECTION.   
           FD  qa-file.   
          $XFD COMMENT  This is a sample file demonstrating directives.   
           01  qa-record.   
               03  animal-info.   
          *(( XFD NAME=PATIENT ))   
                   05  patient-id                  pic x(5).   
                   05  atype                       pic x.   
                   05  ctype redefines atype       pic x.   
                   05  dtype redefines atype       pic x.   
                   05  otype redefines atype       pic x.   
               03  owner-info.   
                   05  phone                       pic x(8).   
                   05  owner                       pic x(30).    
               03  financial.   
                   05  acct_no.   
                       10  year                    pic x(2).   
                       10  seq_no                  pic x(4).   
          *(( XFD DATE=mmddyyyy, USE GROUP ))   
                   05  last_visit.   
                       10  mm                      pic 9(2).   
                       10  dd                      pic 9(2).   
                       10  yyyy                    pic 9(4).   
          $XFD HIDDEN   
                   05  fee                         pic s9(5)v99.   

This directive causes the data dictionary to map PATIENT-ID to PATIENT in the database.

Additional examples

Here are some other places where you may consider using the NAME directive. In all of these instances, note that your COBOL data does not change. The new name appears only in the "virtual" database and in any tables that result from your COBOL code.


Acucorp, Inc.
Voice: (800) 262-6585 (U.S.A. and Canada)
Voice: (858) 689-4500
Fax: (858) 689-4550

Please share your comments on this manual
or on any Acucorp documentation with the
Acucorp Communications Department.
TOCPREVNEXTINDEX
1988-2003 Acucorp, Inc.
All rights reserved.