/* "cascade" will also drop the triggers */
DROP TABLE UNKNOWNPKVC1 cascade;
DROP TABLE UNKNOWNPKVC2 cascade;

CREATE TABLE UNKNOWNPKVC1
(
    ID     NUMBER(38)              PRIMARY KEY,
    NAME   VARCHAR2(32)     NULL,
    VERSION NUMBER(19)         NOT NULL
);

CREATE TABLE UNKNOWNPKVC2
(
    ID     NUMBER(38)              PRIMARY KEY,
    NAME   VARCHAR2(32)        NULL,
    VERSION NUMBER(19)         NOT NULL
);

commit;

CREATE TRIGGER T_UNKNOWNPKVC1
   BEFORE UPDATE ON UNKNOWNPKVC1
   REFERENCING
       NEW AS N_ROW
       OLD AS O_ROW
   FOR EACH ROW
   WHEN (N_ROW.VERSION = O_ROW.VERSION)
   SET N_ROW.VERSION = O_ROW.VERSION + 1
;

commit;

CREATE TRIGGER T_UNKNOWNPKVC2
   BEFORE UPDATE ON UNKNOWNPKVC2
   REFERENCING
       NEW AS N_ROW
       OLD AS O_ROW
   FOR EACH ROW
   WHEN (N_ROW.VERSION = O_ROW.VERSION)
   SET N_ROW.VERSION = O_ROW.VERSION + 1
;

commit;

quit;
