Lets you declare a context variable for a stream or a loop.
Once you have associated a context variable with a relation,
you can use only that context variable to refer to records from
that relation in the record stream you created. Each relation
(including multiple uses of the same relation) in the record
stream must have a unique context variable. For more information
see the entry on Context Variables.
1 – Examples
The following programs demonstrate the use of the relation clause
with a FOR loop. These programs declare a context variable E for
EMPLOYEES. This allows the programs to reference records from the
EMPLOYEES relation by using the variable E in the host language
print statements.
1.1 – C Example
#include <stdio.h>
DATABASE PERS = FILENAME "PERSONNEL";
main()
{
READY PERS;
START_TRANSACTION READ_ONLY;
FOR E IN EMPLOYEES
printf ("%s %s %s\n", E.LAST_NAME,
E.EMPLOYEE_ID,
E.SEX);
END_FOR;
COMMIT;
FINISH;
}
1.2 – Pascal Example
program context_variable (input,output);
DATABASE PERS = FILENAME 'PERSONNEL';
begin
READY PERS;
START_TRANSACTION READ_ONLY;
FOR E IN EMPLOYEES
writeln (E.LAST_NAME, ' ', E.EMPLOYEE_ID, ' ', E.SEX);
END_FOR;
COMMIT;
FINISH;
end.
2 – Format
(B)0[mrelation-clause =
qq> context-var qqq> [4mIN[m qqwqq>qqqqqqqqqqqqqqqqqqwqq> relation-name qq>
mqq> db-handle qq> . qj
2.1 – Format arguments
context-var A context variable. A temporary name that
you associate with a relation. You define
a context variable in a relation clause.
For more information see the entry on
Context Variables.
db-handle Database handle. A host variable used
to refer to a specific database you have
invoked. For more information see the
entry on the Database Handle clause.
relation-name The name of a relation in the database.