Script : Generate SQL using a script which will produce the source code for a function /view /package via Metadata
As an Oracle developer,
many times we want to quickly check the code of a given function/view/package
or a package body to see the current code in the database may be as an
output of a given SQL.
Take example of an
object AP_INVOICES_PKG where we want to check the output
SELECT
'select
dbms_metadata.get_ddl('''
|| object_type
|| ''','''
|| object_name
|| ''') from dual;'
FROM all_objects
WHERE
object_name = 'AP_INVOICES_PKG'
AND object_type NOT IN ('PACKAGE BODY');
The above SQL will give
an output as below
select
dbms_metadata.get_ddl('PACKAGE','AP_INVOICES_PKG') from dual;
And when we run this SQL
, we will get an output which is nothing but the code for package spec and
package body for ap_invoices_pkg.
Comments
Post a Comment