Library /sys$common/syshlp/HELPLIB.HLB  —  RDML72  Statements  CROSS
    Lets you combine records from two or more record streams. You can
    base such record combinations on the relationship between field
    values in separate record streams.

1  –  Examples

    The following programs demonstrate the use of the CROSS clause to
    join records from two relations (a non-equijoin). These programs
    join the relations CURRENT_JOB and JOBS over their common field
    JOB_CODE. This allows these programs to print a report that
    contains fields from both relations. Specifically, these fields
    are: LAST_NAME from the CURRENT_JOBS relation, JOB_CODE from the
    JOBS relation, and JOB_TITLE from the JOBS relation.

1.1  –  C Example

    #include <stdio.h>
    DATABASE PERS = FILENAME "PERSONNEL";

    main()
    {
    READY PERS;
    START_TRANSACTION READ_ONLY;

    FOR C IN CURRENT_JOB
       CROSS J IN JOBS OVER JOB_CODE
          printf ("%s",C.LAST_NAME);
          printf ("  %s",J.JOB_CODE);
          printf ("  %s\n", J.JOB_TITLE);
    END_FOR;

    COMMIT;
    FINISH;
    }

1.2  –  Pascal Example

    program person_job (input,output);
    DATABASE PERS = FILENAME 'PERSONNEL';

    begin
    READY PERS;
    START_TRANSACTION READ_ONLY;

    FOR C IN CURRENT_JOB
       CROSS J IN JOBS OVER JOB_CODE
          writeln (C.LAST_NAME, ' ',J.JOB_CODE, ' ',J.JOB_TITLE);
    END_FOR;

    COMMIT;
    FINISH;
    end.

2  –  Format

  (B)0cross-clause =

  qqwqq> CROSS qqq> relation-clause qqwqq>qqqqqqqqqqqqqqqqqqqqqqqqqqqwqq>
    x                                 mqq> OVER qwq> field-name qqwqwj
    x                                            mqqqqq , <qqqqqqqj x
    x                                                               x
    mqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

2.1  –  Format arguments

    relation-clause        A clause that specifies a context
                           variable for a stream or a loop. For
                           more information see the entry on Context
                           Variables.

    field-name             The name of a field in a relation. For
                           example, once you have defined E as
                           the context variable for the EMPLOYEES
                           relation, E.LAST_NAME is a value
                           expression that refers to a value from
                           the LAST_NAME field of EMPLOYEES.
Close Help