Trigger for each table created outside of CM

Create index on spatial column (only works when table and entries in MAPINFO_CATALOG and MDSYS.SDO_GEOM_METADATA exist) :

 
CREATE INDEX "MAPINFO"."TABLENAME_SX" ON "MAPINFO"."TABLENAME" (GEOLOC) INDEXTYPE IS MDSYS.SPATIAL_INDEX ;
 
 

Create sequence and trigger for ID

 
CREATE SEQUENCE TABLENAME_SEQ INCREMENT BY 1 START WITH 1 MINVALUE 0 CACHE 100;
 

(If table already contains values, start sequence with maxvalue+1)

 
CREATE OR REPLACE TRIGGER "MAPDATA"."TABLENAME_ID"
  before insert on "MAPDATA"."TABLENAME"
  for each row
begin  
  if inserting then
     if :NEW."MI_PRINX" is null then
        select TABLENAME_SEQ.nextval into :NEW."MI_PRINX" from dual;
     end if;
  end if;
end;