
CREATE TABLE "IGLOO"."CATS_ACTIVATION"
  (	"RID" NUMBER NOT NULL ENABLE,
   "CODE" VARCHAR2(255 BYTE) NOT NULL ENABLE,
   "EXPIRE" DATE DEFAULT SYSDATE+7 NOT NULL ENABLE,
    CONSTRAINT "CATS_ACTIVATION_PK" PRIMARY KEY ("IGLOO_ID")
 USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
 STORAGE(INITIAL 262144 NEXT 262144 MINEXTENTS 1 MAXEXTENTS 2147483645
 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
 TABLESPACE "IGLOO_TAB"  ENABLE
  ) SEGMENT CREATION IMMEDIATE
 PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
 STORAGE(INITIAL 262144 NEXT 262144 MINEXTENTS 1 MAXEXTENTS 2147483645
 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
 TABLESPACE "IGLOO_TAB" ;


CREATE OR REPLACE EDITIONABLE TRIGGER "IGLOO"."CATS_ACTIVATION_DATE"
BEFORE INSERT ON CATS_ACTIVATION
FOR EACH ROW
BEGIN
  :new.EXPIRE := SYSDATE + 1;
END;
/
ALTER TRIGGER "IGLOO"."CATS_ACTIVATION_DATE" ENABLE;




create or replace TRIGGER CATS_ACTIVATION_DATE
BEFORE INSERT ON CATS_ACTIVATION
FOR EACH ROW
BEGIN
  :new.EXPIRE := SYSDATE + 1;
END;



# Create procedure

CREATE or REPLACE
procedure CATS_ACTIVATION_DELETE is
begin
delete from "IGLOO"."CATS_ACTIVATION" where EXPIRE < sysdate ;
commit;
end;
/

# Start job

declare
j int;
begin
dbms_job.submit(j,'CATS_ACTIVATION_DELETE;',sysdate,'sysdate+1/1440');
end;
/


# CATS_ACTIVATION_JOB
# AUTO_DROP	FALSE
# INSTANCE_ID
# INSTANCE_STICKINESS	TRUE
# JOB_PRIORITY	3
# JOB_STYLE	REGULAR
# JOB_WEIGHT	1
# LOGGING_LEVEL	OFF
# MAX_FAILURES
# MAX_RUN_DURATION
# MAX_RUNS
# RAISE_EVENTS
# RESTARTABLE	FALSE
# RUN_COUNT	685
# SCHEDULE_LIMIT
# STATE	SCHEDULED
# STOP_ON_WINDOW_CLOSE	FALSE

87e92ff0ad8473eac8ba370b1dff3f6703a316c97d
