Oracle PL/SQL Tutorial/PL SQL Operators/BETWEEN
Версия от 13:45, 26 мая 2010; (обсуждение)
BETWEEN
The BETWEEN operator tests to see if a value falls within a given range of values.
The Syntax for BETWEEN:
the_value [NOT] BETWEEN low_end AND high_end
use < and > rather than BETWEEN in order to eliminate any overlap between conditions
SQL>
SQL> DECLARE
2 salary NUMBER := 20000;
3 employee_id NUMBER := 36325;
4
5 PROCEDURE give_bonus (emp_id IN NUMBER, bonus_amt IN NUMBER) IS
6 BEGIN
7 DBMS_OUTPUT.PUT_LINE(emp_id);
8 DBMS_OUTPUT.PUT_LINE(bonus_amt);
9 END;
10
11 BEGIN
12 IF salary >= 10000 AND salary <= 20000
13 THEN
14 give_bonus(employee_id, 1500);
15 ELSIF salary > 20000 AND salary <= 40000
16 THEN
17 give_bonus(employee_id, 1000);
18 ELSIF salary > 40000
19 THEN
20 give_bonus(employee_id, 500);
21 END IF;
22 END;
23 /
PL/SQL procedure successfully completed.