Creates a record stream containing records with values that fall
within a range you specify.
The BETWEEN conditional expression is true (records are included
in the stream) if the first value expression is between the
second and third value expression, or equal to one of them.
If you precede the BETWEEN expression with the optional NOT
qualifier, the condition is true if there are no records within
the range you specify with the second and third value expression.
The BETWEEN conditional expression sorts records in ascending
order by default. For information on sorting records see the
entry on the SORT statement.
1 – Examples
The following programs demonstrate the use of the BETWEEN
conditional expression with a numeric field. These programs form
a record stream consisting of all the records in the relation
CURRENT_SALARY where the field SALARY_AMOUNT contains a value
greater than or equal to 10,000, and less than or equal to
20,000. These programs print the last name and salary from of
each record in the record stream.
1.1 – C Example
#include <stdio.h>
DATABASE PERS = FILENAME "PERSONNEL";
main()
{
READY PERS;
START_TRANSACTION READ_WRITE;
FOR CS IN CURRENT_SALARY
WITH CS.SALARY_AMOUNT
BETWEEN 10000.00 AND 20000.00
printf ("%s %f\n", CS.LAST_NAME, CS.SALARY_AMOUNT);
END_FOR;
COMMIT;
FINISH;
}
1.2 – Pascal Example
program between_numeric (input,output);
DATABASE PERS = FILENAME 'PERSONNEL';
begin
READY PERS;
START_TRANSACTION READ_ONLY;
FOR CS IN CURRENT_SALARY
WITH CS.SALARY_AMOUNT
BETWEEN 10000.00 AND 20000.00
writeln (CS.LAST_NAME, CS.SALARY_AMOUNT :10:2);
END_FOR;
COMMIT;
FINISH;
end.
2 – Format
(B)0[mbetween-clause =
qqqq> value-expr qqqqqwqq>qqqqqqqwqqq> [4mBETWEEN[m qqqqk
mqq> [4mNOT[m qqj x
lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqj
mqqq> value-expr qqq> [4mAND[m qqq> value-expr qqqqqqq>
2.1 – Format arguments
value-expr A value expression. A symbol or a string
of symbols used to calculate a value. When
you use a value expression in a statement,
Oracle Rdb calculates the value associated
with the expression and uses that value
when executing the statement.