Remote Segment Descriptions

Remote segment descriptions simplify the process of describing hierarchies of RDBMS tables to FOCUS. You can use them for Master and Access Files that provide read-only access to RDBMS tables. You cannot use the same descriptions for MODIFY procedures.

The adapter allows you to create multi-table Master and Access Files that define RDBMS tables or views as segments in the description (see Multi-Table Structures). Each Master File segment description consists of a segment declaration followed by descriptions of all of the fields in the segment (columns of the corresponding table).

It is not unusual for several Master Files to contain a segment description for the same RDBMS table. If a table's description is detailed in one Master File, you can automatically incorporate that description in other Master Files. The syntax is

SEGNAME=segname, PARENT=parent, SEGTYPE= {KL|KLU}, CRFILE=filename,$

where:

segname

Is identical to the SEGNAME in the Master File that contains the full description of the columns in the RDBMS table (the remote Master File).

parent

Is the parent of the segment.

KL

Describes one-to-many relationships.

KLU

Describes unique relationships.

filename

Is the name of the remote Master File that contains the full description of the fields in the segment.

Note:

SEGTYPEs KL and KLU describe segments whose field attributes are described in other Master Files that FOCUS may read at run-time. You can use remote segment descriptions for situations in which several Master Files introduce different views on the same collection of RDBMS tables. You describe the fields of one or several tables in one Master File, and refer to this first file from other Master Files without including all the field descriptions again.

The separately described segment must have the same name in the file in which it is defined and in the file that references it. The CRFILE attribute identifies the Master File that contains the complete segment definition. For example:

SEGNAME=DEPT, PARENT=EMP, SEGTYPE=KL, CRFILE=MAINFILE, $

The adapter obtains the descriptions of fields in the DEPT segment in this file from the DEPT segment in the MAINFILE Master File, where they must physically reside. DEPT cannot be a KL or KLU segment in MAINFILE. Similarly, a dynamic JOIN may not specify a KL or KLU segment as the cross-referenced segment in the target file.

Once you specify the CRFILE attribute in a Master File, that specification becomes the default for subsequently described segments. If you later wish to describe a segment locally (using the traditional method), you must re-specify the local filename using the CRFILE attribute, even though this is not technically a cross-reference. Obviously, the same holds true if you wish to change cross-referenced files from one segment to the next.

FOCUS reads only the field attributes from the segment, not the segment attributes. The MAINFILE Master File does not have to be the description of a real file. It does not need an Access File. It just needs the description of the named segment. Thus, you can set up one large Master File that contains field descriptions of all RDBMS tables or views you may use in reporting, even if you only use the large description for reference, not for reporting.

If you describe the root segment remotely, specify its SEGTYPE as KL.

If two or more segments in a FOCUS Master File represent the same RDBMS table, only one of these segments can have a remote segment description. This requirement is necessary in order to preserve unique SEGNAMEs within the local Master File (because a remote SEGNAME must be identical to its corresponding local SEGNAME).

Remote segment descriptions exist only for convenience. They save typing effort but offer no logical implications regarding parent-child relationships and their implementation.

A Master File that contains remote segment declarations must have its own Access File for defining the relationships between all of its segments (including the remote segments). This local Access File overrides the Access File corresponding to the CRFILE Master File, if one exists.


Top of page

Example: Using a Remote Segment Description

The following example shows the ECOURSE Master File with the COURSE segment described remotely:

FILENAME=ECOURSE     ,SUFFIX=DB2, $
SEGNAME=EMPINFO      ,SEGTYPE=S0, $
 FIELD=EMP_ID        ,ALIAS=EID         ,USAGE=A9    ,ACTUAL=A9,$
 FIELD=LAST_NAME     ,ALIAS=LN          ,USAGE=A15   ,ACTUAL=A15,$
 FIELD=FIRST_NAME    ,ALIAS=FN          ,USAGE=A10   ,ACTUAL=A10,$
 FIELD=HIRE_DATE     ,ALIAS=HDT         ,USAGE=YMD   ,ACTUAL=DATE,$
 FIELD=DEPARTMENT    ,ALIAS=DPT         ,USAGE=A10   ,ACTUAL=A10,
   MISSING=ON,$
 FIELD=CURRENT_SALARY,ALIAS=CSAL        ,USAGE=P9.2  ,ACTUAL=P4,$
 FIELD=CURR_JOBCODE  ,ALIAS=CJC         ,USAGE=A3    ,ACTUAL=A3,$
 FIELD=ED_HRS        ,ALIAS=OJT         ,USAGE=F6.2  ,ACTUAL=F4,
   MISSING=ON,$
 FIELD=BONUS_PLAN    ,ALIAS=BONUS_PLAN  ,USAGE=I4    ,ACTUAL=I4,$
SEGNAME=COURSE ,SEGTYPE=KL  ,PARENT=EMPINFO, CRFILE=COURSE,$

The corresponding Access File is:

SEGNAME = EMPINFO, TABLENAME = "USER1"."EMPINFO", KEYS = 1,
   WRITE = YES,  DBSPACE = PUBLIC.SPACE0,$
SEGNAME = COURSE, TABLENAME = "USER1"."COURSE", KEYS = 2,
   WRITE = YES,     DBSPACE = PUBLIC.SPACE0,
     KEYFLD = EMP_ID, IXFLD = WHO,$

Information Builders