|
| 1 | +prompt Installing utplsql v2-v3 migration utility |
| 2 | + |
| 3 | +set timing off |
| 4 | +set feedback off |
| 5 | +set verify off |
| 6 | +set heading off |
| 7 | +set linesize 1000 |
| 8 | +set pagesize 0 |
| 9 | +set feedback off |
| 10 | +set echo off |
| 11 | +set termout off |
| 12 | +set serveroutput on size unlimited format truncated |
| 13 | + |
| 14 | +column 1 new_value 1 noprint |
| 15 | +column 2 new_value 2 noprint |
| 16 | +select null as "1", null as "2" from dual where 1=0; |
| 17 | +column sep new_value sep noprint |
| 18 | +select '--------------------------------------------------------------' as sep from dual; |
| 19 | + |
| 20 | +spool params.sql.tmp |
| 21 | + |
| 22 | +select |
| 23 | + case |
| 24 | + when '&&1' is null then q'[ACCEPT utplsql_v2_owner CHAR DEFAULT 'UTP' PROMPT 'Provide schema owning the utPLSQL v2 (UTP)']' |
| 25 | + else 'define utplsql_v2_owner=&&1' |
| 26 | + end |
| 27 | +from dual; |
| 28 | +select |
| 29 | + case |
| 30 | + when '&&2' is null then q'[ACCEPT utplsql_v3_owner CHAR DEFAULT 'UT3' PROMPT 'Provide schema owning the utPLSQL v3 (UT3)']' |
| 31 | + else 'define utplsql_v3_owner=&&2' |
| 32 | + end |
| 33 | +from dual; |
| 34 | + |
| 35 | +spool off |
| 36 | + |
| 37 | +set termout on |
| 38 | +@params.sql.tmp |
| 39 | + |
| 40 | +whenever sqlerror exit failure rollback |
| 41 | +whenever oserror exit failure rollback |
| 42 | + |
| 43 | +prompt &&sep |
| 44 | +begin |
| 45 | + execute immediate q'[begin dbms_output.put_line('User &&utplsql_v2_owner owns utPLSQL - version '||&&utplsql_v2_owner..utplsql.version()); end;]'; |
| 46 | +exception |
| 47 | + when others then |
| 48 | + raise_application_error(-20000, 'User &&utplsql_v2_owner does not own utPLSQL v2 or current user('||user||') does not have privileges to access it.'); |
| 49 | +end; |
| 50 | +/ |
| 51 | + |
| 52 | +prompt &&sep |
| 53 | +begin |
| 54 | + execute immediate q'[begin dbms_output.put_line('User &&utplsql_v3_owner owns '||&&utplsql_v3_owner..ut.version()); end;]'; |
| 55 | +exception |
| 56 | + when others then |
| 57 | + raise_application_error(-20000, 'User &&utplsql_v3_owner does not own utPLSQL v3 or current user('||user||') does not have privileges to access it.'); |
| 58 | +end; |
| 59 | +/ |
| 60 | + |
| 61 | +prompt &&sep |
| 62 | +prompt Using schema (&&utplsql_v2_owner) as owner of utPLSQL v2 |
| 63 | +prompt Using schema (&&utplsql_v3_owner) as owner of utPLSQL v3 |
| 64 | + |
| 65 | +alter session set current_schema = &&utplsql_v3_owner; |
| 66 | + |
| 67 | +prompt &&sep |
| 68 | +PROMPT Installing into schema &&utplsql_v3_owner |
| 69 | +prompt &&sep |
| 70 | +set feedback on |
| 71 | +set echo on |
| 72 | +grant execute on sys.utl_file to &&utplsql_v3_owner; |
| 73 | + |
| 74 | +drop public synonym utassert2; |
| 75 | +drop public synonym utassert; |
| 76 | + |
| 77 | +set echo off |
| 78 | +@@install_component.sql 'migration/utassert2.pks' |
| 79 | +@@install_component.sql 'migration/utassert.pks' |
| 80 | +@@install_component.sql 'migration/ut_v2_migration.pks' |
| 81 | + |
| 82 | +@@install_component.sql 'migration/utassert2.pkb' |
| 83 | +@@install_component.sql 'migration/utassert.pkb' |
| 84 | +@@install_component.sql 'migration/ut_v2_migration.pkb' |
| 85 | + |
| 86 | +set echo on |
| 87 | +create or replace public synonym utassert for &&utplsql_v2_owner..utassert; |
| 88 | +create or replace public synonym utassert2 for &&utplsql_v2_owner..utassert2; |
| 89 | +create or replace public synonym ut_v2_migration for ut_v2_migration; |
| 90 | + |
| 91 | +grant execute on utassert to public; |
| 92 | +grant execute on utassert2 to public; |
| 93 | +grant execute on ut_v2_migration to public; |
| 94 | + |
| 95 | +set echo off |
| 96 | +prompt &&sep |
| 97 | +PROMPT Installation completed successfully |
| 98 | +prompt &&sep |
| 99 | + |
| 100 | +set termout off |
| 101 | + |
| 102 | +/* |
| 103 | +* cleanup temporary sql files |
| 104 | +*/ |
| 105 | +--try running on windows |
| 106 | +$ del *.sql.tmp |
| 107 | +--try running on linux/unix |
| 108 | +! rm *.sql.tmp |
| 109 | + |
| 110 | +exit success |
0 commit comments