-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage_export_src.sql
51 lines (43 loc) · 1.21 KB
/
coverage_export_src.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
define l_owner = '&1'
define l_object_name = '&2'
define l_object_type = '&3'
column file_name new_value l_file_name
select replace('report/src/&l_owner..&l_object_name..&l_object_type..sql', ' ', '_') file_name
from dual;
set term off
set echo off
set serveroutput on size unlimited format wrapped
set trimspool on
set linesize 4000
set feedback off
set heading off
set auto off
set trimspool on
set long 32767
set longchunk 32767
set term on
prompt Spooling source of &l_object_type &l_owner..&l_object_name into file &l_file_name
set term off
column text format a255
spool &l_file_name
BEGIN
FOR Line IN (SELECT CASE
WHEN Line = 1 THEN
'CREATE OR REPLACE ' || Text
ELSE
Text
END as Text
FROM all_source
WHERE OWNER = '&l_owner'
AND Name = '&l_object_name'
AND Type = '&l_object_type'
ORDER BY Line) LOOP
dbms_output.put_line(rtrim(rtrim(line.text, chr(13)), chr(10)));
END LOOP;
END;
/
spool off
undefine l_owner
undefine l_object_name
undefine l_object_type
undefine l_file_name