Choose the clause of the RSE you want to see from the following
list.
1 – FIRST
Example 1
Print the first ten records in a relation:
RDO> FOR FIRST 10 E IN EMPLOYEES
cont> SORTED BY E.LAST_NAME
cont> PRINT E.*
cont> END_FOR
Example 2
Use FIRST and SORTED BY to find the maximum values for a field:
RDO> FOR FIRST 5 C IN CURRENT-SALARY
cont> SORTED BY C.SALARY_AMOUNT
cont> PRINT
cont> C.FIRST-NAME,
cont> C.LAST-NAME
cont> END_FOR
Example 3
Use FIRST with a value expression:
&RDB& GET TENTH = ( COUNT OF E IN EMPLOYEES / 10 )
&RDB& START_TRANSACTION READ_WRITE
&RDB& FOR FIRST TENTH E IN EMPLOYEES
SORTED BY E. LAST_NAME
.
.
.
2 – relation-clause
Example 1
Use ERASE:
RDO> FOR E IN EMPLOYEES WITH E.EMPLOYEE_ID = "00334"
cont> ERASE E
cont> END_FOR
Example 2
Use MODIFY:
&RDB& FOR SH IN SALARY_HISTORY
&RDB& WITH SH.EMPLOYEE_ID = ID-NUMBER
&RDB& AND SH.SALARY_END MISSING
&RDB& MODIFY SH USING
&RDB& SH.SALARY_AMOUNT =
&RDB& ( SH.SALARY_AMOUNT + ( 1000 * RATING ) )
&RDB& END_MODIFY
&RDB& END_FOR
Example 3
Use STORE:
&RDB& STORE D IN DEPARTMENTS USING
&RDB& D.DEPARTMENT_NAME = "Recreation";
&RDB& D.DEPARTMENT_CODE = "RECR";
&RDB& D.MANAGER_ID = "00445"
&RDB& END_STORE
Example 4
Use two record streams:
&RDB& FOR E IN EMPLOYEES CROSS
&RDB& J IN JOB_HISTORY WITH
&RDB& E.EMPLOYEE_ID = J.EMPLOYEE_ID
3 – SORT
RDO> FOR E IN EMPLOYEES SORTED BY E.BIRTHDAY
Because this example did not specify the sort order, Oracle Rdb
automatically sorts the EMPLOYEES records in ASCENDING order by
BIRTHDAY.
FOR E IN EMPLOYEES
SORTED BY DESCENDING E.STATUS_CODE,
ASCENDING E.LAST_NAME, E.SOCIAL_SECURITY
If you do not specify ASCENDING or DESCENDING for the second or
subsequent sort keys, Oracle Rdb uses the order you specified for
the preceding sort key.
4 – REDUCED
FOR J IN JOB_HISTORY
WITH J.JOB_END MISSING
REDUCED TO J.JOB_CODE
SORTED BY J.JOB_CODE
PRINT J.JOB_CODE
END_FOR
This example lists all the currently active job codes. It
includes each value in the record stream only once.
5 – CROSS
Create a list of employees and their current salary.
FOR E IN EMPLOYEES CROSS
SH IN SALARY_HISTORY
OVER EMPLOYEE_ID WITH
SH.SALARY_END MISSING
PRINT E.LAST_NAME,
SH.SALARY_AMOUNT
END_FOR
The EMPLOYEES relation contains, among other things, the name
and employee ID of each employee. The SALARY_HISTORY relation
contains a SALARY_AMOUNT for each salary level each employee
has attained and the starting and ending date for each current
salary. For the current salary, the salary ending date is
missing. These relations share the common field, EMPLOYEE_ID.
Therefore, you can use CROSS to join them over this field.
6 – VIEWS
This view definition incorporates an RSE that includes a CROSS
operation.
DEFINE VIEW CURRENT_JOB OF JH IN JOB_HISTORY
CROSS E IN EMPLOYEES OVER EMPLOYEE_ID
WITH JH.JOB_END MISSING.
E.LAST_NAME.
E.FIRST_NAME.
E.EMPLOYEE_ID.
JH.JOB_CODE.
JH.DEPARTMENT_CODE.
JH.SUPERVISOR_ID.
JH.JOB_START.
JH.JOB_END.
END VIEW.