oracle

 
CREATE SEQUENCE OP_LOG_SEQ
  START WITH 1
  MAXVALUE 9999999999999999999999999999
  MINVALUE 1
  NOCYCLE
  CACHE 10
  NOORDER;
     
CREATE OR REPLACE TRIGGER OP_LOG_TRG BEFORE INSERT ON OP_LOG
FOR EACH ROW
BEGIN
  BEGIN
    IF :NEW.LOGID IS NULL THEN
      SELECT OP_LOG_SEQ.NEXTVAL INTO :NEW.LOGID FROM DUAL;
    END IF;
  END;
END;

利用 trigger 補上流水號

CREATE SEQUENCE OP_LOG_SEQ

  START WITH 1

  MAXVALUE 9999999999999999999999999999

  MINVALUE 1

  NOCYCLE

  CACHE 10

  NOORDER;

     

CREATE OR REPLACE TRIGGER OP_LOG_TRG BEFORE INSERT ON OP_LOG

FOR EACH ROW

BEGIN

  BEGIN

    IF :NEW.LOGID IS NULL THEN

      SELECT OP_LOG_SEQ.NEXTVAL INTO :NEW.LOGID FROM DUAL;

    END IF;

  END;

END;

© 2015 版權所有。

Create a website for freeWebnode