Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated install/uninstall scripts to improve readability.
  • Loading branch information
jgebal committed Jun 27, 2017
commit e1a3fa785ae22633c9f43362ab549eaa34a88827
4 changes: 2 additions & 2 deletions source/create_synonyms_and_grants_for_public.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework
*/

@@define_ut3_owner_param.sql

set echo off
set feedback on
set heading off
set verify off

define ut3_owner = &1

prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to PUBLIC

whenever sqlerror exit failure rollback
Expand Down
25 changes: 22 additions & 3 deletions source/create_synonyms_and_grants_for_user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,33 @@
Create all necessary grant for the user who owns test packages and want to execute utPLSQL framework
*/

@@define_ut3_owner_param.sql

column 2 new_value 2 noprint
select null as "2" from dual where 1=0;
spool params.sql.tmp
select
case
when '&&2' is null then q'[ACCEPT ut3_user CHAR PROMPT 'Provide schema name where synonyms for the utPLSQL v3 should be created ']'
else 'define ut3_user=&&2'
end
from dual;
spool off
set termout on
@params.sql.tmp
set termout off
/* cleanup temporary sql files */
--try running on windows
$ del params.sql.tmp
--try running on linux/unix
! rm params.sql.tmp
set termout on

set echo off
set feedback on
set heading off
set verify off

define ut3_owner = &1
define ut3_user = &2

prompt Granting privileges on UTPLSQL objects in &&ut3_owner schema to user &&ut3_user

whenever sqlerror exit failure rollback
Expand Down
36 changes: 36 additions & 0 deletions source/define_ut3_owner_param.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
set serveroutput on size unlimited format truncated
whenever oserror continue

set heading off
set linesize 1000
set pagesize 0

set verify off
set define on

set termout off
set timing off
set feedback off

column line_separator new_value line_separator noprint
select '--------------------------------------------------------------' as line_separator from dual;

column 1 new_value 1 noprint
select null as "1" from dual where 1=0;
spool params.sql.tmp
select
case
when '&&1' is null then q'[ACCEPT ut3_owner CHAR DEFAULT 'UT3' PROMPT 'Provide schema for the utPLSQL v3 (UT3)']'
else 'define ut3_owner=&&1'
end
from dual;
spool off
set termout on
@params.sql.tmp
set termout off
/* cleanup temporary sql files */
--try running on windows
$ del params.sql.tmp
--try running on linux/unix
! rm params.sql.tmp
set termout on
27 changes: 15 additions & 12 deletions source/install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,20 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
prompt Installing utplsql framework

set serveroutput on size unlimited
set feedback on
set timing off
set verify off
set define &
@@define_ut3_owner_param.sql

spool install.log

define ut3_owner = &1
prompt &&line_separator
prompt Installing utPLSQL v3 framework
prompt &&line_separator

whenever sqlerror exit failure rollback
whenever oserror exit failure rollback
set serveroutput on size unlimited format truncated

set feedback off
prompt Switching current schema to &&ut3_owner
prompt &&line_separator
alter session set current_schema = &&ut3_owner;
alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6003,6009,6010,7206)';
--set define off
Expand Down Expand Up @@ -89,8 +86,11 @@ alter session set plsql_warnings = 'ENABLE:ALL', 'DISABLE:(5004,5018,6000,6001,6
@@install_component.sql 'core/ut_expectation_processor.pks'
@@install_component.sql 'core/ut_expectation_processor.pkb'

--installing profiler tabs if they dont exist
prompt Installing PLSQL profiler objects into &&ut3_owner schema
prompt You will see "ORA-00955" errors if they already exist
prompt &&line_separator
whenever sqlerror continue
set feedback on
@@core/coverage/proftab.sql
whenever sqlerror exit failure rollback

Expand Down Expand Up @@ -266,21 +266,24 @@ column text format a100
column error_count noprint new_value error_count

prompt Validating installation
select name, type, sequence, line, position, text, count(1) over() error_count
prompt &&line_separator
set heading on
select type, name, sequence, line, position, text, count(1) over() error_count
from all_errors
where owner = upper('&&ut3_owner')
and name not like 'BIN$%' --not recycled
and (name = 'UT' or name like 'UT\_%' escape '\')
-- errors only. ignore warnings
and attribute = 'ERROR'
order by name, type, sequence
/

begin
if to_number('&&error_count') > 0 then
raise_application_error(-20000, 'Not all sources were successfully installed.');
else
dbms_output.put_line('Installation completed successfully');
dbms_output.put_line('--------------------------------------------------------------');
dbms_output.put_line('&&line_separator');
end if;
end;
/
Expand Down
5 changes: 3 additions & 2 deletions source/install_component.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
set heading off
set feedback off
exec dbms_output.put_line('Installing component '||upper(regexp_substr('&&1','\/(\w*)\.',1,1,'i',1)));
set feedback on
@@&&1
show errors
exec dbms_output.put_line('--------------------------------------------------------------');
set feedback off
exec dbms_output.put_line('&&line_separator');

6 changes: 3 additions & 3 deletions source/install_headless.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ define ut3_user = ut3
define ut3_password = XNtxj8eEgA6X6b6f
define ut3_tablespace = users

@@create_utplsql_owner.sql &&ut3_user &&ut3_password &&ut3_tablespace
@@install.sql &&ut3_user
@@create_synonyms_and_grants_for_public.sql &&ut3_user
@@create_utplsql_owner.sql &&ut3_owner &&ut3_password &&ut3_tablespace
@@install.sql &&ut3_owner
@@create_synonyms_and_grants_for_public.sql &&ut3_owner

exit
25 changes: 16 additions & 9 deletions source/uninstall.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
prompt Uninstalling UTPLSQL v3 framework
set serveroutput on size unlimited format truncated
set verify off
@@define_ut3_owner_param.sql

set feedback on
set define on

spool uninstall.log

define ut3_owner = &1
prompt &&line_separator
prompt Uninstalling UTPLSQL v3 framework
prompt &&line_separator

alter session set current_schema = &&ut3_owner;
set echo on
Expand Down Expand Up @@ -250,17 +250,22 @@ drop type ut_varchar2_rows force;

set echo off
set feedback off
declare
i integer := 0;
begin
dbms_output.put_line('Dropping synonyms pointing to non-existing objects in schema '||upper('&&ut3_owner'));
for syn in (
select
case when owner = 'PUBLIC'
then 'public synonym '
else 'synonym ' || owner || '.' end || synonym_name as syn_name,
table_owner||'.'||table_name as for_object
from all_synonyms
from all_synonyms s
where table_owner = upper('&&ut3_owner') and table_owner != owner
and not exists (select 1 from all_objects o where o.owner = s.table_owner and o.object_name = s.table_name)
)
loop
i := i + 1;
begin
execute immediate 'drop '||syn.syn_name;
dbms_output.put_line('Dropped '||syn.syn_name||' for object '||syn.for_object);
Expand All @@ -269,12 +274,14 @@ begin
dbms_output.put_line('FAILED to drop '||syn.syn_name||' for object '||syn.for_object);
end;
end loop;
dbms_output.put_line('&&line_separator');
dbms_output.put_line(i||' synonyms dropped');
end;
/
begin
dbms_output.put_line('--------------------------------------------------------------');
dbms_output.put_line('Uninstall complete');
dbms_output.put_line('--------------------------------------------------------------');
dbms_output.put_line('&&line_separator');
dbms_output.put_line('Uninstall complete');
dbms_output.put_line('&&line_separator');
end;
/

Expand Down