(B)0[mcross-clause =
qwq> [4mCROSS[m qq> relation-clause qwqqqqqqqqqqqqqqqqqqqqqqqqqqqqwqwqq>
x mqq> [4mOVER[m qwq> field-name qwqj x
x mqqqqqq , <qqqqqj x
mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
Lets you combine records from two or more record streams. You
can join these records in combinations based on the relationship
between the values of fields in the separate record streams. This
combining of records is called a relational join.
1 – More
The RDO documentation indicates that views do not allow
updates to returned data. They do not specify this
restriction on a cross of two relations from the same
database. Oracle Rdb allows it to work if you use a WITH
clause.
Any field that appears in the RSE (record selection
expression) is marked as read-only. You cannot update these
fields as this may remove the record from the join, or add
a new record to the join that will not be recognized.
In general, the record stream created by a join (CROSS)
cannot be updated. A workaround is to fetch the RDB$DB_KEY
in the loop and generate a separate FOR loop to modify the
value. The following example shows this situation:
#include stdio
DATABASE MAPB = FILENAME "[rdml]PERSONNEL";
main()
{
READY MAPB;
START_TRANSACTION READ_WRITE;
printf("Entering EMPLOYEES & JOB_HISTORY relations:\n\n");
FOR E IN EMPLOYEES
CROSS JH IN JOB_HISTORY OVER EMPLOYEE_ID
WITH (JH.EMPLOYEE_ID > "00000" OR E.FIRST_NAME STARTING
WITH "A-")
SORTED BY E.LAST_NAME
FOR E1 IN EMPLOYEES WITH E1.RDB$DB_KEY = E.RDB$DB_KEY
printf("\n\n%s %s < found ",E1.FIRST_NAME ,E1.LAST_NAME);
MODIFY E1 USING
strcpy(E1.FIRST_NAME,"Xavier ");
printf("\n%s %s < changed",E1.FIRST_NAME,E.LAST_NAME);
END_MODIFY;
END_FOR;
END_FOR;
printf("\n\nRolling Back the modifys");
ROLLBACK;
FINISH;
printf("\n\nFinished");
}