Thursday, November 7, 2019

APEX 19.2: Finally, API for component export

I don't remember when I was so excited about the new APEX feature as at the moment when I've discovered that there's a new parameter in procedure apex_export.get_application called p_components that enables component export. I know, it's small, but it opens a big playground.

Maybe the reason for this excitement is that for some time now, I'm working on an APEX app for creating patches of database object and APEX components and the only missing piece was API for component export. I had that working before APEX 19.2, but I had to use an internal export procedure which is not so convenient.

The only thing that you could do with the apex_export API before 19.2 was to export a whole application or all components in some predefined structure.

From APEX 19.2 you can export any component that you want through the API. So, how can you do that...

The Code...

... is pretty straight forward. Just select component from a new dictionary APEX_APPL_EXPORT_COMPS. The columns that you need for component export are TYPE_NAME and ID, for example:

Then you should combine them in the array in form TYPE_NAME:ID (currently there's a bug in 19.2 docs, where you can find that the array values should be formed as TYPE:NAME):

The output of the get_application procedure is a table of apex_t_export_file (with name and contents columns). Name column will always have same value (in format f{APP_ID}_components.sql, for example, f100_components.sql) and the contents column will have export code (as a CLOB). No matter how many components do you add to the array you'll always get only one file/element as an output. The only time when you can get more files is if you set p_split parameter to true.

After that, you can spool code into SQL file as shown in the example in the documentation or play with it in so many different ways. For example, one of the ways is to create an application to manage your APEX component exports (with nice filenames), as shown here

More about that in the next blog post.

Tested in APEX



  1. Hi Marko,
    Thank you for all the work you do for the community!!!
    There is a little typo on line 14. It should be: dbms_output.put_line(v_files(1).contents);

    Kind regards,