Sunday, November 20, 2016

A fast way to load a Gitora repository with many objects

I find creating a Gitora repository for a large schema or for many schemas via the Gitora user interface a little tedious.
Luckily there is the Gitora API to help us out.

So here is a little example of how to bulk load your objects into a gitora repository.

First create your repositories in the Gitora UI..
Ten use this script (and obviously replace 'YOUR_SOURCE_SCHEMAS' and  'TARGET_REPOSITORY_NAME').

   for i in (select o.object_name
             ,      o.object_type
             ,      o.owner
             from  all_objects o
             where o.object_name not like 'Z_%'         -- some rules for which objects to load.
             and   o.object_name not in ('QMS_EXEC_SQL'
             and   o.object_type in (api_gitora.type_function
             and o.owner in ('YOUR_SOURCE_SCHEMAS')
             order by o.owner
             ,        o.object_type
          api_gitora.adddbobject(in_schema_cd   => i.owner
                                ,in_type_cd     => i.object_type
                                ,in_name_tx     => i.object_name
                                ,in_reponame_tx => 'TARGET_REPOSITORY_NAME' -- to which respository need the objects go

          -- If you want lto log what is loaded, remember to increase your dbms_output buffer!
          dbms_output.put_line('inserted: '||i.object_type||' '||i.owner||'.'||i.object_name);

          when others 
             dbms_output.put_line('error on: '||i.object_type||' '||i.owner||'.'||i.object_name||'   sqlerrm: '||sqlerrm);
   end loop;
Quick and easy. Have fun!

No comments:

Post a Comment