Page 1 of 1

Trigger to Assign sequence as PK

Posted: Mon Nov 29, 2021 4:11 am
by admin
create or replace SEQUENCE JS_HEALTH_CHECK_seq start with 1 nocache;

CREATE OR REPLACE TRIGGER JS_HEALTH_CHECK_BIU
before insert OR UPDATE ON JS_HEALTH_CHECK
for each row
BEGIN
IF :NEW.ID IS NULL THEN
SELECT JS_HEALTH_CHECK_seq.nextval INTO :NEW.ID FROM sys.dual;
END IF;
END;
/