Tuesday, 18 January 2022

Exporting app from an old version of APEX

 

ORACLE APEX application export tip

Exporting app from an old version of APEX is possible!!!!!


In case you upgraded your APEX instance so that previous version of APEX is still available and you need to do an export for whatever reason you might read this post. 
 
I learned today that we can still export out all apps from an old APEX schema too. How we would do this? 

Our situation was that we upgraded instance to APEX 21.1.5 from APEX 20.02 a month or so ago and due to some research we needed to get the old APEX exports.
 
Theory goes, if we directly connect to the old apex schema (apex_200200), we should still be able to export the old application from the old APEX schema.
 
What is best is we can be using pure SQL to do this. This is link to APEX 20.02 API documentation

You may be familiar with the code above from earlier or newer versions of APEX but here it comes really handy.
 
An obvious example that come to my mind is -  instead of worrying will your app export be backward compatible maybe this can be an official workaround better than trying to manually hack it.
 
We had to tweak this code to make it work on APEX 200200 schema due to existing public synonyms in place so:
variable name varchar2(255)
variable contents clob
declare
  l_files apex_200200.wwv_flow_t_export_files;
begin
  l_files := apex_200200.wwv_flow_export_api.get_application( p_application_id => 100);
  :name := l_files(1).name;
  :contents := l_files(1).contents;
end;
/
set feed off echo off head off flush off termout off trimspool on
set long 100000000 longchunksize 32767
col name new_val name
select :name name from sys.dual;
spool &name.
print contents
spool off
Voilà!!! we have an app export from an old APEX version like we never upgraded it. 
 
In case you are using SQLcl or APEXExport method they may not work now because of already mentioned synonyms in place and clearly as some APIs have been updated between the two APEX versions.

To verify the story if you opened the exported file you would see that it looks like any good old export we did before. There should be a release reference to 20.02 version and not 21.01 which would normally happen in situation after the upgrade. 

Thanks to Patrick and Carsten from APEX team for sharing this tip. I am just sharing it here in case someone needs it in the future.
 

An interesting thing would be to figure out how far back you can take this but that is a material for another day. 

Happy APEXing,
Lino 

No comments:

Post a Comment