Trigger to update – TSTZ

This trigger below need be created before the impdp – execution. This will avoid ORA-39405 During Import – The insane way

Create the trigger below and replace the property according to your error. This will correct/update the timezone – but this will work only if your imported data will not have columns with timezone property. Make your adjusts – like the owner, the table name and property values.

CREATE OR REPLACE TRIGGER sys.create_table_trigger
  AFTER CREATE ON DATABASE
declare
  sql_text varchar2(200);
BEGIN
  IF DICTIONARY_OBJ_TYPE = 'TABLE' and ora_dict_obj_name = 'SYS_IMPORT_FULL_01' and ORA_SYSEVENT = 'CREATE' THEN
    sql_text := 'CREATE OR REPLACE TRIGGER update_timezone BEFORE INSERT OR UPDATE ON sys.SYS_IMPORT_FULL_01 ' ;
    sql_text := sql_text || ' FOR EACH ROW WHEN (new.property > 0) BEGIN ';
    sql_text := sql_text || ' if ' || ':' || 'new.property=32 then ';
    sql_text := sql_text  || ' :' || 'new.property:=42;';
    sql_text := sql_text  || ' end if;';
    sql_text := sql_text  || ' END; ';
    execute immediate sql_text ;
  end if;
END;



Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *