Skip to Main Content
  • Questions
  • How to generate DDL for APEX app from code

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Peter.

Asked: February 27, 2019 - 7:27 am UTC

Last updated: September 25, 2023 - 1:09 pm UTC

Version: 5.1.

Viewed 10K+ times! This question is

You Asked

In Oracle SQL Developer, 'Application Express' section, we can export DDL for an APEX app by context menu, 'Quick DDL' > 'Save to Worksheet' menu.

I'd like to do the same by executing some SQL or PL/SQL code.

I know we have DBMS_METADATA.GET_DDL, but that doesn't work for APEX objects.

How can I accomplish this? Thank you!

and Connor said...

There are PLSQL API's to allow this. Here's some pseudo code to export all apps

declare
  cursor c_apps is
    select application_id
    ,      workspace
    from   apex_applications
    where  workspace not in ('INTERNAL'
                            ,'COM.ORACLE.APEX.REPOSITORY'
                            ,'COM.ORACLE.CUST.REPOSITORY')
    order  by application_id;
    l_export_clob  clob;
begin
  apex_custom_auth.set_user('ADMIN'); 
  for i in c_apps
  loop
     wwv_flow_api.set_security_group_id(apex_util.find_security_group_id(i.workspace));
     l_export_clob := wwv_flow_utilities.export_application_to_clob (i.application_id);
     insert into apex_exports values ( .... , l_export_clob );
  end loop;

end;
/


Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Peter Elekes, February 28, 2019 - 8:13 am UTC

Thank you, it works!

My other idea was apex_util.export_application, but that was undocumented and involved exporting results to a file and getting it back.
Connor McDonald
March 01, 2019 - 1:11 am UTC

Glad we could help

apex_export.get_application

Stew Ashton, September 16, 2023 - 6:23 am UTC

More recent versions of APEX include the documented and explicitly supported
apex_export
package.

Best regards,
Stew Ashton
Chris Saxon
September 25, 2023 - 1:09 pm UTC

Thanks for sharing

More to Explore

APEX

Keep your APEX skills fresh by attending their regular Office Hours sessions.