ALTER TABLE CT_ODS.A_LOAD_HISTORY RENAME COLUMN A_ETL_LOAD_SET_KEY  TO A_WORKFLOW_HISTORY_KEY;

create or replace TRIGGER "CT_ODS"."AUTOKEY_A_LOAD_HISTORY"
  BEFORE INSERT
  ON "CT_ODS"."A_LOAD_HISTORY"
  FOR EACH ROW

DECLARE
    e_more_than_28_digits EXCEPTION;

BEGIN
  IF :NEW.A_WORKFLOW_HISTORY_KEY IS NULL THEN
    :NEW.A_WORKFLOW_HISTORY_KEY := AUTOKEY_A_LOAD_HISTORY.NEXTVAL;
    ELSE
        -- Informatica PowerCenter cannot handle more than 28 significant places
        -- so raise exception if more were given manually
        IF :NEW.A_WORKFLOW_HISTORY_KEY > 9999999999999999999999999999 THEN
            RAISE e_more_than_28_digits;
        END IF;
  END IF;
END;
/