Tests for the presence of a single record in a record stream.
A UNIQUE conditional expression is true if the record stream
specified by the record selection expression consists of only one
record.
If you precede the UNIQUE expression with the optional NOT
qualifier, the condition is true if there is more than one record
in the record stream or if the stream is empty.
1 – Examples
The following programs demonstrate the use of the UNIQUE
conditional expression. These programs join the relations
EMPLOYEES and DEGREES over their common field, EMPLOYEE_ID. The
UNIQUE expression limits the record stream to those records in
the EMPLOYEES relation that have only one corresponding record
in the DEGREES relation. These programs print an informational
message and the selected employees first and last name in
alphabetical order, based on the last name.
1.1 – C Example
#include <stdio.h>
DATABASE PERS = FILENAME "PERSONNEL";
main()
{
READY PERS;
START_TRANSACTION READ_ONLY;
FOR E IN EMPLOYEES
SORTED BY E.FIRST_NAME
WITH UNIQUE D IN DEGREES WITH D.EMPLOYEE_ID = E.EMPLOYEE_ID
printf("%s %s has one and only one college degree.\n",
E.FIRST_NAME, E.LAST_NAME);
END_FOR;
COMMIT;
FINISH;
}
1.2 – Pascal Example
program unique_expr (input,output);
DATABASE PERS = FILENAME 'PERSONNEL';
begin
READY PERS;
START_TRANSACTION READ_ONLY;
FOR E IN EMPLOYEES
WITH UNIQUE D IN DEGREES WITH D.EMPLOYEE_ID = E.EMPLOYEE_ID
writeln (E.FIRST_NAME, ' ', E.LAST_NAME,
' has one and only one college degree.');
END_FOR;
COMMIT;
FINISH;
end.
2 – Format
(B)0[munique-clause =
qqqwqq>qqqqqqqwqqqqqqqqqq> [4mUNIQUE[m qqqqqqwq>qqqqqqqqqqqqqqqqqqwqqqqk
mqq> [4mNOT[m qqj mq> handle-options qqj x
x
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
mqqqqqqqqqqqqqq> rse qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq>
(B)0[mhandle-options =
q> ( qwqqqqqq> [4mREQUEST_HANDLE[m qqqqq> var qqqqqqqqwq> ) q>
tqqqqqq> [4mTRANSACTION_HANDLE[m qqq> var qqqqqqqqu
mqqqqqq> [4mREQUEST_HANDLE[m q> var q> , qqqqqqqk x
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj x
mqqqq> [4mTRANSACTION_HANDLE[m q> var qqqqqqqqqqqj
2.1 – Format arguments
rse A record selection expression. A phrase
that defines specific conditions that
individual records must meet before
Oracle Rdb includes them in a record stream.
handle-options A request handle, a transaction handle, or
both.
REQUEST_HANDLE var The REQUEST_HANDLE keyword followed by a
host language variable. A request handle
identifies a compiled Oracle Rdb request.
If you do not supply a request handle
explicitly, RDML associates a unique
request handle for the compiled request.
TRANSACTION_HANDLE The TRANSACTION_HANDLE keyword followed by
var a host language variable. A transaction
handle identifies a transaction. If
you do not supply a transaction handle
explicitly, RDML uses the default
transaction handle.