set echo off
--
-- exp_object_source.sql
--
-- Objects - Export the source of an object to a file. The filename will be as follows: expobj_{object_name}_{instance}_{date}.ddl
--
-- Usage: @exp_object_source object_name
-- Example: @exp_object_source pk_test
--
set termout off
set verify off
set doc off
set feedback off
set recsep off
set pagesize 0
--
define objectname=&&1
--
define lsize=200
set linesize &&lsize
--
Column instance noprint NEW_VALUE v_instance
select upper(value) instance from v$parameter where name = 'db_name';
--
Column TODAY noprint NEW_VALUE TODAY_DATE
select to_char(sysdate, 'YYYYMMDD') TODAY from dual;
--
define out_file=expobj_&&objectname&&v_instance&&TODAY_DATE..DDL
--define out_file=expobj_&&objectname..DDL
spool &&out_file
--
SELECT text
from user_source
where name like upper('&&objectname')
order by decode(type,'FUNCTION',1,'PROCEDURE',2,'PACKAGE',3,'PACKAGE BODY',4,5),name,line
;
spool off
UNDEFINE LSIZE
UNDEFINE TODAY_DATE
UNDEFINE v_instance
UNDEFINE objectname
UNDEFINE OUT_FILE
UNDEFINE 1
column today clear
column instance clear
set doc off
set feedback on
set pagesize 30
set termout on
set echo on
-- exit
|