Saved Interactive Reports, Lost and Found
Sometimes we can too quickly say “No” when we should take a moment to think about whether we can actually say “Yes”. This was one of those times for me.
We had just gone live with a fairly big system move + upgrade – a suite of APEX applications shifted from one database instance running APEX 5 to another instance running version 19.1. The migration went smoothly. After the new instance was released to the business to do some final shakedown testing, they noticed one problem:
“All our saved reports are gone.”
Oops. We had built the new instance by simply importing each application from source control; since these scripts don’t include the Saved Report formats that users had customised in many of the Interactive Reports in prod, they didn’t get migrated to the new database.
When they asked if we can transfer the saved reports across, I initially replied, “Sorry, we can’t” – thinking that redoing the migration from scratch with a full export from the old database, followed by re-doing all the app changes, was going to take too much time and effort.
A minute later, I sent another email. “Hold that thought – there is a way.” I’d forgotten that my script for exporting the applications uses an APEX API with some parameters that until now I’d rarely used, but which would solve our problem. My script included this:
wwv_flow_utilities.export_application_to_clob ( p_application_id => 100, p_export_ir_public_reports => 'N', p_export_ir_private_reports => 'N', p_export_ir_notifications => 'N');
NOTE: on more recent versions this API became supported as
In order to restore all the user saved reports, I created a new version of my export script, but changed all the “N”s into “Y”s:
wwv_flow_utilities.export_application_to_clob ( p_application_id => 100, p_export_ir_public_reports => 'Y', p_export_ir_private_reports => 'Y', p_export_ir_notifications => 'Y');
I call this the “Yes” script. Using this “Yes” script, we performed the following steps:
- Log into the schema on the old database
(we hadn’t shut it down yet, thankfully – we’d just locked the schemas and set all the applications to “Unavailable”)
- Run the “Yes” script.
Rename the resulting export files, e.g. f100_ir.sql, f110_ir.sql, etc.
- Log into the new database.
- Run the IR scripts (f100_ir.sql, etc.).
This reverted all the applications to their old versions, but they included all the user’s saved reports.
- Re-import the new versions of the applications from source control.
This upgraded all the applications, leaving the user’s saved reports intact.