CREATE OR REPLACE TRIGGER TR_LAYERFIELDTYPESDETAIL_BI
  BEFORE INSERT
  ON LAYERFIELDTYPESDETAIL
  FOR EACH ROW
begin

-- - - - - - - - - - - - -
-- BI_(0)
-- Create 01.07.2013
-- - - - - - - - - - - - -

    if (:new.id is null) then 
     select g_shared.NEXTVAL into :new.id from dual; end if;
    if (:new.mask is null) then 
     :new.mask := '';
    end if; 
    if (:new.regexp is null) then 
     :new.regexp := '';
    end if; 
    if ((:new.fieldsize is null) or (:new.fieldsize < 0))  then 
     :new.fieldsize := 0;
    end if; 

-- - - - - - - - - - - - -
-- BI_500
-- Create 01.07.2013
-- - - - - - - - - - - - -
  :NEW.CreateDate := SYSDATE;
  :NEW.UpdateDate := :NEW.CreateDate;
  :NEW.CreaterUser := USER;
  :NEW.UpdaterUser := USER;
end;
/

CREATE OR REPLACE TRIGGER TR_LAYERFIELDTYPESDETAIL_BU
  BEFORE UPDATE
  ON LAYERFIELDTYPESDETAIL
  FOR EACH ROW
begin

-- - - - - - - - - - - - -
-- BU_(0)
-- Create 01.07.2013
-- - - - - - - - - - - - -

    if (:new.mask is null) then 
     :new.mask := '';
    end if; 
    if (:new.regexp is null) then 
     :new.regexp := '';
    end if; 
    if ((:new.fieldsize is null) or (:new.fieldsize < 0))  then 
     :new.fieldsize := 0;
    end if; 
    
-- - - - - - - - - - - - -
-- BU_500
-- Create 01.07.2013
-- - - - - - - - - - - - -
    :new.UpdateDate := SYSDATE;
    :new.UpdaterUser := User;
end;
/

commit work;