You’re using ORDS.
You’ve written some web services.
Now you need to control the underlying PL/SQL source.
How do I get the code out?
There’s a few ways.
1. Use SQL Developer
On the Module, mouse right click.
2. Use SQLcl
The REST command will get what you want.
If you want this in a file, just use the SPOOL command.
3. Get it Yourself with SQL
The ORDS_METADATA schema comes with some PL/SQL packages for managing your web services. One of those is named ‘ORDS_EXPORT’ – one guess what this does 🙂
SET long 5000 SET pagesize 1000 SELECT ORDS_METADATA.ords_export.export_module(p_module_name=>'ora_magazine') FROM dual;
Which comes out looking pretty familiar…
If you look at the package.function, you’ll notice it’s overloaded – you can also pass a couple of BOOLEANs to determine if you want the code to ENABLE the schema or if you want the associated PRIVILEGES included.
You see these same options when using the GUI and saying export to file.
4. Via REST Development
If you use this panel, you can export all of your MODULES to an archive (ZIP) of XML files that which can then be uploaded to another ORDS server if you want. I wouldn’t recommend using this method unless you only have REST access to ORDS, or in other words, no DATABASE access where the REST services are defined.