DROP TRIGGER T_UNKNOWNPKVC1;
DROP TRIGGER T_UNKNOWNPKVC2;

DROP TABLE UNKNOWNPKVC1;
DROP TABLE UNKNOWNPKVC2;

CREATE TABLE UNKNOWNPKVC1
(
    ID     DECIMAL(32)              PRIMARY KEY,
    NAME   VARCHAR(32)     ,
    VERSION   DECIMAL(19)      NOT NULL
);

CREATE TABLE UNKNOWNPKVC2
(
    ID     DECIMAL(32)              PRIMARY KEY,
    NAME   VARCHAR(32)     ,
    VERSION   DECIMAL(19)      NOT NULL
);

commit;

CREATE TRIGGER T_UNKNOWNPKVC1
   UPDATE ON UNKNOWNPKVC1
   REFERENCING OLD AS old NEW AS new
   FOR EACH ROW
       WHEN (new.VERSION = old.VERSION)
       (
           UPDATE UNKNOWNPKVC1 SET VERSION = old.VERSION + 1
       );
/

CREATE TRIGGER T_UNKNOWNPKVC2
   UPDATE ON UNKNOWNPKVC2
   REFERENCING OLD AS old NEW AS new
   FOR EACH Row
       WHEN (new.VERSION = old.VERSION)
       (
           UPDATE UNKNOWNPKVC2 SET VERSION = old.VERSION + 1
       );
/

commit;

quit;
