Skip to content

Commit 8d78168

Browse files
David FRANCODavid FRANCO
authored andcommitted
Tweaked a bit with the error treatment on the clean schema script; creates a simple proc that generate a random password with minimal security; minor changes on the findObjects and getUserGrants scripts
1 parent 6d3b35e commit 8d78168

File tree

5 files changed

+59
-7
lines changed

5 files changed

+59
-7
lines changed

cleanSchema.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ begin
6666
execute immediate 'drop table '||tbl.owner||'.'||tbl.table_name||' cascade constraints purge';
6767
--dbms_output.put_line('drop table '||tbl.owner||'.'||tbl.table_name||' cascade constraints purge');
6868
exception
69-
when no_data_found then
69+
when others then
7070
dbms_output.put_line('ERROR: Drop failed on Table: '||tbl.owner||'.'||tbl.table_name||' --> '|| sqlerrm);
7171
end;
7272
end loop;
@@ -78,7 +78,7 @@ begin
7878
execute immediate 'drop '||obj.object_type||' '||obj.owner||'.'||obj.object_name;
7979
--dbms_output.put_line('drop '||obj.object_type||' '||obj.owner||'.'||obj.object_name);
8080
exception
81-
when no_data_found then
81+
when others then
8282
dbms_output.put_line('ERROR: Drop failed on '||obj.object_type||': '||obj.owner||'.'||obj.object_name||' --> '|| sqlerrm);
8383
end;
8484
end loop;
@@ -90,7 +90,7 @@ begin
9090
execute immediate 'drop '||pkg.object_type||' '||pkg.owner||'.'||pkg.object_name;
9191
--dbms_output.put_line('drop '||pkg.object_type||' '||pkg.owner||'.'||pkg.object_name);
9292
exception
93-
when no_data_found then
93+
when others then
9494
dbms_output.put_line('ERROR: Drop failed on '||pkg.object_type||': '||pkg.owner||'.'||pkg.object_name||' --> '|| sqlerrm);
9595
end;
9696
end loop;
@@ -102,7 +102,7 @@ begin
102102
dbms_scheduler.drop_job(job.owner||'.'||job.object_name);
103103
--dbms_output.put_line('dbms_scheduler.drop_job('||job.owner||'.'||job.object_name||')');
104104
exception
105-
when no_data_found then
105+
when others then
106106
dbms_output.put_line('ERROR: Drop failed on JOB: '||job.owner||'.'||job.object_name||' --> '|| sqlerrm);
107107
end;
108108
end loop;
@@ -114,7 +114,7 @@ begin
114114
dbms_scheduler.drop_schedule(schedule.owner||'.'||schedule.object_name);
115115
--dbms_output.put_line('dbms_scheduler.drop_schedule('||schedule.owner||'.'||schedule.object_name||')');
116116
exception
117-
when no_data_found then
117+
when others then
118118
dbms_output.put_line('ERROR: Drop failed on SCHEDULE: '||schedule.owner||'.'||schedule.object_name||' --> '|| sqlerrm);
119119
end;
120120
end loop;

createRandPass.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
set lines 190 pages 50000 long 10000
2+
set serveroutput on size unlimited
3+
4+
DECLARE
5+
vPasswd varchar2(50);
6+
BEGIN
7+
vPasswd := DBMS_RANDOM.STRING('a', 1);
8+
FOR i IN 1 .. 11
9+
LOOP
10+
CASE ROUND(DBMS_RANDOM.VALUE(1,5))
11+
WHEN 1 THEN
12+
vPasswd := vPasswd || ROUND(DBMS_RANDOM.VALUE(0, 10));
13+
WHEN 2 THEN
14+
vPasswd := vPasswd || '#';
15+
ELSE
16+
vPasswd := vPasswd || DBMS_RANDOM.STRING('a', 1);
17+
END CASE;
18+
END LOOP;
19+
DBMS_OUTPUT.PUT_LINE(vPasswd);
20+
END;
21+
/

findObject.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ SELECT DISTINCT OWNER,
1616
STATUS
1717
FROM DBA_OBJECTS
1818
WHERE OBJECT_NAME like upper('%' || :v_owner || '%')
19-
ORDER BY 2, 3
19+
ORDER BY 1, 2, 3
2020
;

getCompilationErrors.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
set lines 230 pages 5000 long 10000
2+
col owner for a20
3+
col name for a30
4+
col "LIN/POS" for a8
5+
col text for a168
6+
7+
select OWNER,
8+
NAME,
9+
LINE || '/' || POSITION as "LIN/POS",
10+
TEXT
11+
from dba_errors
12+
where owner = 'REPORTWEB'
13+
order by owner, name, SEQUENCE
14+
;
15+
16+
17+
/*
18+
SQL> desc dba_errors
19+
Name Null? Type
20+
----------------------------------------- -------- ----------------------------
21+
OWNER NOT NULL VARCHAR2(30)
22+
NAME NOT NULL VARCHAR2(30)
23+
TYPE VARCHAR2(12)
24+
SEQUENCE NOT NULL NUMBER
25+
LINE NOT NULL NUMBER
26+
POSITION NOT NULL NUMBER
27+
TEXT NOT NULL VARCHAR2(4000)
28+
ATTRIBUTE VARCHAR2(9)
29+
MESSAGE_NUMBER NUMBER
30+
*/

getGrants.sql renamed to getUserGrants.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ where grantee in (:v_owner)
1515
union all
1616
select 'grant '||privilege||' on '||owner||'.'||table_name||' to '||grantee||';'
1717
from dba_tab_privs
18-
where grantee in (:v_owner);
18+
where grantee in (:v_owner)
19+
;

0 commit comments

Comments
 (0)