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)0[mcross-clause =
qqwqq> [4mCROSS[m qqq> relation-clause qqwqq>qqqqqqqqqqqqqqqqqqqqqqqqqqqwqq>
x mqq> [4mOVER[m 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.