SQL>
SQL> CREATE TABLE incremented_values
2 (value_inserted NUMBER,
3 value_incremented NUMBER);
Table created.
SQL>
SQL> CREATE OR REPLACE TRIGGER increment_by_one
2 BEFORE INSERT ON incremented_values
3 FOR EACH ROW
4 BEGIN
5 :new.value_incremented := :new.value_incremented + 1;
6 END;
7 /
Trigger created.
SQL>
SQL> CREATE OR REPLACE TRIGGER increment_by_two
2 BEFORE INSERT ON incremented_values
3 FOR EACH ROW
4 BEGIN
5 IF :new.value_incremented > 1 THEN
6 :new.value_incremented := :new.value_incremented + 2;
7 END IF;
8 END;
9 /
Trigger created.
SQL>
SQL> INSERT INTO incremented_values VALUES(1,1);
1 row created.
SQL>
SQL> SELECT * FROM incremented_values;
VALUE_INSERTED VALUE_INCREMENTED
-------------- -----------------
1 2
SQL>
SQL>
SQL> DROP TABLE incremented_values;
Table dropped.
SQL>
|