Thursday, January 28, 2016

Get a PLSQL code dump of all your Oracle database code.

I used to work as a part time DBA and when I was doing my supposedely menial tasks like unlocking accounts. One of the frequent request was to get an code for the object a Function or Package or Trigger.

While this was trivial task to get an single object code it had to be quick. I never bothered to write any code or script to get that.
 However one day a developer came and asked me for a code dump for a whole schema ( We had 2500 eligible objects). What he wanted was the code dump for every plsql object stored in the system. This included triggers, functions, procedures , packages. So I searched the internet and came up with a code to do that. It was fairly small 10 liner code which was astonishing. Curiously I never saw the function used anywhere.

The function clob2file is from package dbms_xslprocessor. This one is available in oracle 11g so if you ever found yourself yearning to dump a clob object to file you should try using this. There was just a little problem I wanted to get this dump from 10G database; So I went ahead and wrote a simple script. This script is given below.

 Note : that commented line starting with dbms_xslprocessor works with oracle 11g only you should use either of the 11g or 10g call not both  so one call should always be co. You also need to modify directory names and schema names (SCOTT )


Thanks.

No comments:

Post a Comment

Please leave your relevant comments and questions only.

AWS solution architect exam questions.

Before taking this let it be known that the questions are sourced from random sites using simple algorithms. The authenticity of questions a...