set serveroutput on size 99999999;
declare
vCursor number;
vComando varchar2(2000);
vError number;
vUser varchar2(200);
begin
select user into vUser from dual;
if (vUser = 'APPS' or vUser = 'SYSTEM' or vUSer = 'SYS') then
dbms_output.put_line('SCHEMA NÃO PERMITIDO');
else
dbms_output.put_line('DROPANDO OBJETOS');
vCursor := dbms_sql.open_cursor;
for rObjetos in (select *
from user_objects
where object_type in
('TABLE','FUNCTION','PROCEDURE','SYNONYM','VIEW','PACKAGE','SEQUENCE')
) loop
vComando := 'Drop '||rObjetos.object_type|| ' ' || rObjetos.object_name;
if rObjetos.object_type = 'TABLE' then
vComando := vComando || ' cascade constraint';
end if;
dbms_sql.parse(vCursor, vComando, dbms_sql.native);
vError := dbms_sql.execute(vCursor);
end loop;
dbms_sql.close_cursor(vCursor);
end if;
end;
/
declare
vCursor number;
vComando varchar2(2000);
vError number;
vUser varchar2(200);
begin
select user into vUser from dual;
if (vUser = 'APPS' or vUser = 'SYSTEM' or vUSer = 'SYS') then
dbms_output.put_line('SCHEMA NÃO PERMITIDO');
else
dbms_output.put_line('DROPANDO OBJETOS');
vCursor := dbms_sql.open_cursor;
for rObjetos in (select *
from user_objects
where object_type in
('TABLE','FUNCTION','PROCEDURE','SYNONYM','VIEW','PACKAGE','SEQUENCE')
) loop
vComando := 'Drop '||rObjetos.object_type|| ' ' || rObjetos.object_name;
if rObjetos.object_type = 'TABLE' then
vComando := vComando || ' cascade constraint';
end if;
dbms_sql.parse(vCursor, vComando, dbms_sql.native);
vError := dbms_sql.execute(vCursor);
end loop;
dbms_sql.close_cursor(vCursor);
end if;
end;
/
já ouvi histórias de um APPS rodando isso ... hehehe
ResponderExcluir