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 apex_export.get_application
.
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.
Problem solved.
andreml
21 June 2020 - 4:53 pm
Well, this is what I would call “thinking like an engineer”.
A little bit like Apollo 13 🙂
ankit bhatt
14 July 2020 - 9:08 pm
Wow.. we have faced a similar issue in the past but unfortunately, we didn’t know this functionality
Thanks for sharing 🙂
Phil
3 October 2022 - 4:24 am
What about this situation: development has been ongoing for 2 weeks and LIVE now has a number of saved public and private reports.
How do we export those reports before replacing the app with the new version and then importing those reports please?
This must be possible? I recall APEXEport did similar?
I’ve tried exporting as a zip which puts all the files into components, and with public reports specified, there is no files with names looking like “saved IR reports”
Jeffrey Kemp
4 October 2022 - 4:20 pm
Hi Phil,
Don’t export and re-import the reports in the Live environment; instead, export the application only from Dev. That way, when you update Live with the new version of the application, it won’t overwrite the user’s saved reports.