@@ -945,7 +945,10 @@ sql_tablespaces() {
945945 DECLARE
946946 type x is table of varchar2(20000) index by pls_integer;
947947 xx x;
948+ l_open varchar2(32);
948949 begin
950+ select open_mode into l_open from v\$ database;
951+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
949952 begin
950953 execute immediate 'select upper(decode(${IGNORE_DB_NAME:- 0}
951954 , 0, decode(vp.con_id, null, d.NAME
@@ -994,6 +997,7 @@ sql_tablespaces() {
994997 dbms_output.put_line(cur1.name || '| Debug (121) 1: ' ||sqlerrm);
995998 end loop;
996999 end;
1000+ end if;
9971001 END;
9981002 /
9991003 set serverout off"
@@ -1002,7 +1006,10 @@ sql_tablespaces() {
10021006 DECLARE
10031007 type x is table of varchar2(20000) index by pls_integer;
10041008 xx x;
1009+ l_open varchar2(32);
10051010 begin
1011+ select open_mode into l_open from v\$ database;
1012+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
10061013 begin
10071014 execute immediate 'select upper(decode(${IGNORE_DB_NAME:- 0}
10081015 , 0, decode(dbf.con_id, null, d.NAME
@@ -1086,6 +1093,7 @@ sql_tablespaces() {
10861093 dbms_output.put_line(cur1.name || '| Debug (121) 2: ' ||sqlerrm);
10871094 end loop;
10881095 end;
1096+ end if;
10891097 END;
10901098 /
10911099 set serverout off"
@@ -1096,7 +1104,10 @@ sql_tablespaces() {
10961104 DECLARE
10971105 type x is table of varchar2(20000) index by pls_integer;
10981106 xx x;
1107+ l_open varchar2(32);
10991108 begin
1109+ select open_mode into l_open from v\$ database;
1110+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
11001111 begin
11011112 execute immediate 'select upper(decode(${IGNORE_DB_NAME:- 0} , 0, d.NAME, i.instance_name))
11021113 || ''|'' || file_name ||''|''|| tablespace_name ||''|''|| fstatus ||''|''|| AUTOEXTENSIBLE
@@ -1129,6 +1140,7 @@ sql_tablespaces() {
11291140 dbms_output.put_line(cur1.name || '| Debug (102) 1: ' ||sqlerrm);
11301141 end loop;
11311142 end;
1143+ end if;
11321144 END;
11331145 /
11341146 set serverout off"
@@ -1137,7 +1149,10 @@ sql_tablespaces() {
11371149 DECLARE
11381150 type x is table of varchar2(20000) index by pls_integer;
11391151 xx x;
1152+ l_open varchar2(32);
11401153 begin
1154+ select open_mode into l_open from v\$ database;
1155+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
11411156 begin
11421157 execute immediate 'select upper(decode(${IGNORE_DB_NAME:- 0}
11431158 , 0, dbf.name
@@ -1207,36 +1222,62 @@ sql_tablespaces() {
12071222 dbms_output.put_line(cur1.name || '| Debug (102) 2: ' ||sqlerrm);
12081223 end loop;
12091224 end;
1225+ end if;
12101226 END;
12111227 /
12121228 set serverout off"
12131229
12141230 elif [ " $NUMERIC_ORACLE_VERSION " -ge 92 ]; then
1215- echo " select upper(decode(${IGNORE_DB_NAME:- 0} , 0, d.NAME, i.instance_name))
1216- || '|' || file_name ||'|'|| tablespace_name ||'|'|| fstatus ||'|'|| AUTOEXTENSIBLE
1217- ||'|'|| blocks ||'|'|| maxblocks ||'|'|| USER_BLOCKS ||'|'|| INCREMENT_BY
1218- ||'|'|| ONLINE_STATUS ||'|'|| BLOCK_SIZE
1219- ||'|'|| decode(tstatus,'READ ONLY', 'READONLY', tstatus) || '|' || free_blocks
1220- ||'|'|| contents
1231+ echo " SET SERVEROUTPUT ON feedback off
1232+ DECLARE
1233+ type x is table of varchar2(20000) index by pls_integer;
1234+ xx x;
1235+ l_open varchar2(32);
1236+ begin
1237+ select open_mode into l_open from v\$ database;
1238+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
1239+ begin
1240+ execute immediate 'select upper(decode(${IGNORE_DB_NAME:- 0} , 0, d.NAME, i.instance_name))
1241+ || ''|'' || file_name ||''|''|| tablespace_name ||''|''|| fstatus ||''|''|| AUTOEXTENSIBLE
1242+ ||''|''|| blocks ||''|''|| maxblocks ||''|''|| USER_BLOCKS ||''|''|| INCREMENT_BY
1243+ ||''|''|| ONLINE_STATUS ||''|''|| BLOCK_SIZE
1244+ ||''|''|| decode(tstatus,''READ ONLY'', ''READONLY'', tstatus) || ''|'' || free_blocks
1245+ ||''|''|| contents
12211246 from v\$ database d , v\$ instance i, (
12221247 select f.file_name, f.tablespace_name, f.status fstatus, f.AUTOEXTENSIBLE,
12231248 f.blocks, f.maxblocks, f.USER_BLOCKS, f.INCREMENT_BY,
1224- 'ONLINE' ONLINE_STATUS, t.BLOCK_SIZE, t.status tstatus, nvl(sum(fs.blocks),0) free_blocks, t.contents
1249+ '' ONLINE' ' ONLINE_STATUS, t.BLOCK_SIZE, t.status tstatus, nvl(sum(fs.blocks),0) free_blocks, t.contents
12251250 from dba_data_files f, dba_tablespaces t, dba_free_space fs
12261251 where f.tablespace_name = t.tablespace_name
12271252 and f.file_id = fs.file_id(+)
12281253 group by f.file_name, f.tablespace_name, f.status, f.autoextensible,
1229- f.blocks, f.maxblocks, f.user_blocks, f.increment_by, 'ONLINE',
1254+ f.blocks, f.maxblocks, f.user_blocks, f.increment_by, '' ONLINE' ',
12301255 t.block_size, t.status, t.contents
12311256 UNION
1232- select f.file_name, f.tablespace_name, 'ONLINE' status, f.AUTOEXTENSIBLE,
1233- f.blocks, f.maxblocks, f.USER_BLOCKS, f.INCREMENT_BY, 'TEMP',
1234- t.BLOCK_SIZE, 'TEMP' status, sum(sh.blocks_free) free_blocks, 'TEMPORARY'
1257+ select f.file_name, f.tablespace_name, '' ONLINE' ' status, f.AUTOEXTENSIBLE,
1258+ f.blocks, f.maxblocks, f.USER_BLOCKS, f.INCREMENT_BY, '' TEMP' ',
1259+ t.BLOCK_SIZE, '' TEMP'' status, sum(sh.blocks_free) free_blocks, '' TEMPORARY' '
12351260 from v\$ thread th, dba_temp_files f, dba_tablespaces t, v\$ temp_space_header sh
12361261 WHERE f.tablespace_name = t.tablespace_name and f.file_id = sh.file_id
1237- GROUP BY th.instance, f.file_name, f.tablespace_name, 'ONLINE',
1262+ GROUP BY th.instance, f.file_name, f.tablespace_name, '' ONLINE' ',
12381263 f.autoextensible, f.blocks, f.maxblocks, f.user_blocks, f.increment_by,
1239- 'TEMP', t.block_size, t.status);"
1264+ ''TEMP'', t.block_size, t.status)'
1265+ bulk collect into xx;
1266+ if xx.count >= 1 then
1267+ for i in 1 .. xx.count loop
1268+ dbms_output.put_line(xx(i));
1269+ end loop;
1270+ end if;
1271+ exception
1272+ when others then
1273+ for cur1 in (select upper(name) name from v\$ database) loop
1274+ dbms_output.put_line(cur1.name || '| Debug (92): ' || sqlerrm);
1275+ end loop;
1276+ end;
1277+ end if;
1278+ END;
1279+ /
1280+ set serverout off"
12401281 fi
12411282
12421283 echo ' PROMPT '
@@ -1560,7 +1601,10 @@ sql_resumable() {
15601601 DECLARE
15611602 type x is table of varchar2(20000) index by pls_integer;
15621603 xx x;
1604+ l_open varchar2(32);
15631605 begin
1606+ select open_mode into l_open from v\$ database;
1607+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
15641608 begin
15651609 execute immediate 'select upper(i.INSTANCE_NAME)
15661610 ||''|''|| u.username
@@ -1592,6 +1636,7 @@ sql_resumable() {
15921636 dbms_output.put_line(cur1.instance_name || '| Debug: '||sqlerrm);
15931637 end loop;
15941638 end;
1639+ end if;
15951640 END;
15961641 /
15971642 set serverout off"
@@ -1607,7 +1652,10 @@ sql_jobs() {
16071652 DECLARE
16081653 type x is table of varchar2(20000) index by pls_integer;
16091654 xx x;
1655+ l_open varchar2(32);
16101656 begin
1657+ select open_mode into l_open from v\$ database;
1658+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
16111659 begin
16121660 execute immediate 'SELECT upper(vp.name)
16131661 ||''|''|| j.OWNER
@@ -1657,6 +1705,7 @@ sql_jobs() {
16571705 dbms_output.put_line(cur1.name || '| Debug (121): ' ||sqlerrm);
16581706 end loop;
16591707 end;
1708+ end if;
16601709 END;
16611710 /
16621711 set serverout off"
@@ -1668,7 +1717,10 @@ sql_jobs() {
16681717 DECLARE
16691718 type x is table of varchar2(20000) index by pls_integer;
16701719 xx x;
1720+ l_open varchar2(32);
16711721 begin
1722+ select open_mode into l_open from v\$ database;
1723+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
16721724 begin
16731725 execute immediate 'SELECT upper(decode(${IGNORE_DB_NAME:- 0} , 0, vd.NAME, i.instance_name))
16741726 ||''|''|| j.OWNER
@@ -1707,6 +1759,7 @@ sql_jobs() {
17071759 dbms_output.put_line(cur1.name || '| Debug (102): ' ||sqlerrm);
17081760 end loop;
17091761 end;
1762+ end if;
17101763 END;
17111764 /
17121765 set serverout off"
@@ -1718,18 +1771,43 @@ sql_jobs() {
17181771sql_ts_quotas () {
17191772 echo ' PROMPT '
17201773 echo ' PROMPT <<<oracle_ts_quotas:sep(124)>>>'
1721- echo " select upper(decode(${IGNORE_DB_NAME:- 0} , 0, d.NAME, i.instance_name))
1722- ||'|'|| Q.USERNAME
1723- ||'|'|| Q.TABLESPACE_NAME
1724- ||'|'|| Q.BYTES
1725- ||'|'|| Q.MAX_BYTES
1774+ echo " SET SERVEROUTPUT ON feedback off
1775+ DECLARE
1776+ type x is table of varchar2(20000) index by pls_integer;
1777+ xx x;
1778+ l_open varchar2(32);
1779+ begin
1780+ select open_mode into l_open from v\$ database;
1781+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
1782+ begin
1783+ execute immediate 'select upper(decode(${IGNORE_DB_NAME:- 0} , 0, d.NAME, i.instance_name))
1784+ ||''|''|| Q.USERNAME
1785+ ||''|''|| Q.TABLESPACE_NAME
1786+ ||''|''|| Q.BYTES
1787+ ||''|''|| Q.MAX_BYTES
17261788 from dba_ts_quotas Q, v\$ database d, v\$ instance i
17271789 where max_bytes > 0
17281790 union all
17291791 select upper(decode(${IGNORE_DB_NAME:- 0} , 0, d.NAME, i.instance_name))
1730- ||'|||'
1792+ ||'' |||' '
17311793 from v\$ database d, v\$ instance i
1732- order by 1;"
1794+ order by 1'
1795+ bulk collect into xx;
1796+ if xx.count >= 1 then
1797+ for i in 1 .. xx.count loop
1798+ dbms_output.put_line(xx(i));
1799+ end loop;
1800+ end if;
1801+ exception
1802+ when others then
1803+ for cur1 in (select upper(name) name from v\$ database) loop
1804+ dbms_output.put_line(cur1.name || '| Debug ts_quotas: ' || sqlerrm);
1805+ end loop;
1806+ end;
1807+ end if;
1808+ END;
1809+ /
1810+ set serverout off"
17331811 echo ' PROMPT '
17341812}
17351813
@@ -2010,7 +2088,10 @@ sql_locks_old() {
20102088 DECLARE
20112089 type x is table of varchar2(20000) index by pls_integer;
20122090 xx x;
2091+ l_open varchar2(32);
20132092 begin
2093+ select open_mode into l_open from v\$ database;
2094+ if l_open in ('READ WRITE', 'READ ONLY WITH APPLY') then
20142095 begin
20152096 execute immediate 'select upper(i.instance_name)
20162097 || ''|'' || a.sid
@@ -2046,6 +2127,7 @@ sql_locks_old() {
20462127 dbms_output.put_line(cur1.instance_name || '| Debug (101): '||sqlerrm);
20472128 end loop;
20482129 end;
2130+ end if;
20492131 END;
20502132 /
20512133 set serverout off"
0 commit comments