Skip to content

Commit

Permalink
Updates to build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkurtz committed Oct 11, 2022
1 parent 0ca32a7 commit 5a68ca2
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 29 deletions.
32 changes: 16 additions & 16 deletions nvision_dynamic_selectors.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ROLLBACK;
ALTER SESSION SET current_schema=SYSADM;
GRANT SELECT on SYS.V_$SQL TO sysadm;

set echo on pages 99 lines 180 trimspool on
set echo on pages 99 lines 220 trimspool on
spool nvision_dynamic_selectors
--------------------------------------------------------------------------------
--selector logging table
Expand Down Expand Up @@ -80,7 +80,7 @@ END;
/
show errors
ALTER TRIGGER sysadm.xx_nvision_end DISABLE;
pause
--pause
--------------------------------------------------------------------------------
--mark/unmark static selectors
--------------------------------------------------------------------------------
Expand All @@ -105,7 +105,7 @@ END;
/
--DROP TRIGGER sysadm.xx_pstreeselctl_inc;
show errors
pause
--pause

--------------------------------------------------------------------------------
--one-time fix to populate selector log with static selectors
Expand All @@ -124,7 +124,7 @@ COMMIT
--------------------------------------------------------------------------------
--one-time fix to populate selector log with contents of tree selector
--------------------------------------------------------------------------------
set serveroutput on
set serveroutput on size unlimited
DECLARE
l_sql CLOB;
BEGIN
Expand Down Expand Up @@ -321,7 +321,7 @@ END;
--------------------------------------------------------------------------------
--one-time fix to add partition name to selector log
--------------------------------------------------------------------------------
set serveroutput on
set serveroutput on size unlimited
DECLARE
l_selector_num INTEGER;
BEGIN
Expand Down Expand Up @@ -374,23 +374,24 @@ END;
@@treeselector_triggers
/*-------------------------------------------------------------------------------------------------------------------------------------
/*--Test script
/*-------------------------------------------------------------------------------------------------------------------------------------
set pages 99 lines 200 serveroutput on
spool nvision_dynamic_selectors append
-------------------------------------------------------------------------------------------------------------------------------------
--Test script
-------------------------------------------------------------------------------------------------------------------------------------
set pages 99 lines 220 serveroutput on
column selector_num heading 'Selector|Number' format 9999999
column table_name format a18
column ownerid heading 'Owner ID' format a8
column partition_position heading 'Part|Pos' format 999
column partition_name format a20
column partition_name heading 'Partition|Name' format a20
column process_instance heading 'Process|Instance' format 99999999
column length format 99
column num_rows heading 'Num|Rows'
column length heading 'Len' format 99
column num_rows heading 'Number|of Rows' format 9999999
column high_value format a20
column client_info format a48
column module format a12
column timestamp format a28
-------------------------------------------------------------------------------------------------------------------------------------
rollback;
exec dbms_application_info.set_module('TEST_MODULE','TEST_ACTION');
delete from ps_nvs_treeslctlog where selector_num = 42;
Expand Down Expand Up @@ -443,9 +444,8 @@ delete from ps_nvs_treeslctlog where selector_num = 42;
/*-------------------------------------------------------------------------------------------------------------------------------------*/
ttitle 'Tree Selector Log'
set pages 99 lines 200 termout off
set pages 99 lines 220 termout off
column business_unit format a5 heading 'Business|Unit'
column process_instance heading 'Process|Instance'
column tree_name format a18
column report_id format a18
column layout_id format a18
Expand Down Expand Up @@ -499,7 +499,7 @@ order by selector_num
TTITLE OFF
set termout on
---------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------
--drop extended stats from partitioned tree selectors
---------------------------------------------------------------------------------------*
BEGIN
Expand Down
64 changes: 64 additions & 0 deletions pstreeselect_interval_partitioning.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
REM pstreeselect_interval_partitioning.sql

set echo on
REM spool &&2._pstreeselect&&1._interval_partitioning
spool pstreeselect_interval_partitioning append

ALTER SESSION SET CURRENT_SCHEMA=&&2.;

DROP TABLE &&2..PSYPSTREESELECT&&1. PURGE
/

CREATE TABLE &&2..PSYPSTREESELECT&&1.
(SELECTOR_NUM INTEGER NOT NULL,
TREE_NODE_NUM INTEGER NOT NULL,
RANGE_FROM_&&1. VARCHAR2(&&1.) NOT NULL,
RANGE_TO_&&1. VARCHAR2(&&1.) NOT NULL)
PARTITION BY RANGE (selector_num) INTERVAL (1)
(PARTITION VALUES LESS THAN(2))
TABLESPACE "PTWORK" STORAGE(INITIAL 64K NEXT 64K)
/
INSERT INTO &&2..PSYPSTREESELECT&&1.
(SELECTOR_NUM,
TREE_NODE_NUM,
RANGE_FROM_&&1.,
RANGE_TO_&&1.)
SELECT SELECTOR_NUM,
TREE_NODE_NUM,
RANGE_FROM_&&1.,
RANGE_TO_&&1.
FROM &&2..PSTREESELECT&&1.
/

DROP TABLE &&2..PSTREESELECT&&1. PURGE;
/
ALTER TABLE &&2..PSYPSTREESELECT&&1. RENAME TO PSTREESELECT&&1.
/

CREATE UNIQUE INDEX &&2..PS_PSTREESELECT&&1. ON &&2..PSTREESELECT&&1.
(SELECTOR_NUM
,TREE_NODE_NUM
,RANGE_FROM_&&1.
,RANGE_TO_&&1.)
local PCTFREE 5 COMPRESS 1 TABLESPACE "PSINDEX" STORAGE(INITIAL 64K NEXT 64K)
/
ALTER INDEX &&2..PS_PSTREESELECT&&1. NOPARALLEL LOGGING
/
CREATE INDEX &&2..PSAPSTREESELECT&&1. ON &&2..PSTREESELECT&&1.
(SELECTOR_NUM
,RANGE_FROM_&&1.
,RANGE_TO_&&1.
,TREE_NODE_NUM)
local PCTFREE 5 COMPRESS 1 TABLESPACE "PSINDEX" STORAGE(INITIAL 64K NEXT 64K)
/
ALTER INDEX &&2..PSAPSTREESELECT&&1. NOPARALLEL LOGGING
/

--add your own roles here
GRANT SELECT ON &&2..pstreeselect&&1. TO sysadm;
GRANT SELECT ON &&2..pstreeselect&&1. TO ps_read_all_role;
GRANT SELECT ON &&2..pstreeselect&&1. TO ace_read_only;
GRANT SELECT ON &&2..pstreeselect&&1. TO psteam;
GRANT SELECT, INSERT, UPDATE, DELETE ON &&2..pstreeselect&&1. TO ace_read_write;

spool off
28 changes: 28 additions & 0 deletions rebuild_interval_treeselector.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
REM rebuild_interval_treeselector.sql
set pages 0 head off feedback off echo off
spool pstreeselect_interval_partitioning
spool C:\Users\DAKURT0\Documents\sql\rebuild_interval_treeselector1.sql
with u as (
SELECT username
FROM dba_users
WHERE (username = 'SYSADM' OR username like 'NVEXEC%')
), r as (
SELECT recname, DECODE(sqltablename,' ','PS_'||recname,sqltablename) sqltablename
, SUBSTR(recname,-2) n
FROM psrecdefn
WHERE recname like 'PSTREESELECT__'
)
SELECT '@@C:\Users\DAKURT0\Documents\sql\pstreeselect_interval_partitioning.sql', r.n, u.username
FROM u, r
--WHERE r.n = 1
ORDER BY r.n, u.username
--FETCH FIRST 10 ROWS ONLY
/
spool off
set pages 99 head on feedback on echo on verify on
spool rebuild_interval_treeselector
clear screen
alter session set current_schema = SYSADM;
EXEC sysadm.psft_Ddl_lock.set_Ddl_permitted(true);
@@C:\Users\DAKURT0\Documents\sql\rebuild_interval_treeselector1
EXEC sysadm.psft_Ddl_lock.set_Ddl_permitted(false);
2 changes: 1 addition & 1 deletion treeselector_statprefs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ begin
,'FOR ALL COLUMNS SIZE AUTO FOR COLUMNS SIZE 254 SELECTOR_NUM TREE_NODE_NUM FOR COLUMNS SIZE 1 RANGE_FROM_'||i.length||
' RANGE_TO_'||i.length||' (SELECTOR_NUM, TREE_NODE_NUM) (SELECTOR_NUM, RANGE_FROM_'||i.length||') (SELECTOR_NUM, RANGE_TO_'||i.length||')'
);
dbms_stats.gather_table_stats(i.owner,i.table_name);
--dbms_stats.gather_table_stats(i.owner,i.table_name);
END LOOP;
end;
/
Expand Down
7 changes: 4 additions & 3 deletions treeselector_triggers.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REM treeselector_triggers.sql
set serveroutput on echo on
set serveroutput on size unlimited echo on
clear screen
spool treeselector_triggers
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -54,7 +54,8 @@ EXCEPTION WHEN OTHERS THEN
dbms_output.put_line(''Error:''||l_err_msg);
END after statement;
END;';
dbms_output.put_line(l_cmd);
--dbms_output.put_line(l_cmd);
dbms_output.put_line('TRIGGER '||i.owner||'.'||LOWER(i.recname||'_'||i.action));
EXECUTE IMMEDIATE l_cmd;
END LOOP;
END;
Expand All @@ -70,6 +71,6 @@ where table_name like 'PSTREESEL%'
order by 1,2,3
/

EXEC DBMS_UTILITY.compile_schema(schema => 'SYSADM');
--EXEC DBMS_UTILITY.compile_schema(schema => 'SYSADM', compile_all=>FALSE);

spool off
30 changes: 21 additions & 9 deletions xx_nvision_selectors.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
REM xx_nvision_selectors.sql
set echo on
set echo on timi on
spool xx_nvision_selectors
rollback;
ALTER SESSION SET current_schema=SYSADM;
Expand Down Expand Up @@ -59,7 +59,7 @@ k_lookup_tree_name CONSTANT BOOLEAN := TRUE; --enable lookup of tree name in v$s
-------------------------------------------------------------------------------------------------------
--package global variables
-------------------------------------------------------------------------------------------------------
l_debug_level INTEGER := 8; -- variable to hold debug level of package
l_debug_level INTEGER := 5; -- variable to hold debug level of package
l_debug_indent INTEGER := 0; -- indent level of procedure
-------------------------------------------------------------------------------------------------------
g_selector_num INTEGER :=0;
Expand Down Expand Up @@ -135,30 +135,29 @@ BEGIN

--1.12.2017 also purge any control record in case static to maintain integrity
l_cmd := 'DELETE FROM '||p_ownerid||'.pstreeselctl WHERE selector_num = :1';
debug_msg(l_cmd||','||p_selector_num);
debug_msg(l_cmd||','||p_selector_num,6);
EXECUTE IMMEDIATE l_cmd USING p_selector_num;

IF l_partition_name IS NULL THEN
l_cmd := 'DELETE FROM '||p_ownerid||'.'||l_table_name||' WHERE selector_num = :1';
debug_msg(l_cmd||','||p_selector_num);
debug_msg(l_cmd||','||p_selector_num,6);
EXECUTE IMMEDIATE l_cmd USING p_selector_num;
ELSE
BEGIN
-- l_cmd := 'SELECT COUNT(*) FROM '||l_table_name||' PARTITION ('||l_partition_name||')';
-- EXECUTE IMMEDIATE l_cmd INTO l_num_rows;
-- debug_msg(l_cmd||':'||l_num_rows);

l_cmd := 'ALTER TABLE '||p_ownerid||'.'||l_table_name||' TRUNCATE PARTITION '||l_partition_name||' UPDATE INDEXES DROP STORAGE';
l_cmd := 'ALTER TABLE '||p_ownerid||'.'||l_table_name||' TRUNCATE PARTITION '||l_partition_name||' DROP STORAGE UPDATE INDEXES';
--cannot drop partitions because they do not get created again when the selector number recycles
--l_cmd := 'ALTER TABLE '||p_ownerid||'.'||l_table_name||' DROP PARTITION '||l_partition_name||' UPDATE INDEXES';

debug_msg(l_cmd);
debug_msg(l_cmd,6);
EXECUTE IMMEDIATE l_cmd;
l_cmd := '';

UPDATE ps_nvs_treeslctlog l
SET partition_name = ' '
, status_flag = 'X'
SET status_flag = 'X'
WHERE selector_num = p_selector_num
AND partition_name = l_partition_name
RETURNING job_no INTO l_job_no;
Expand Down Expand Up @@ -461,6 +460,7 @@ BEGIN
, p.high_value, p.high_value_length
FROM all_tab_partitions p
WHERE p.table_name LIKE 'PSTREESELECT__'
AND (p.table_owner = 'SYSADM' OR p.table_owner LIKE 'NVEXEC%')
)
SELECT x.*
FROM x
Expand Down Expand Up @@ -563,6 +563,7 @@ BEGIN
SELECT owner, table_name
FROM all_tables
WHERE table_name = 'PSTREESELCTL'
AND (owner = 'SYSADM' OR owner like 'NVEXEC%')
) LOOP
l_sql := 'DELETE FROM '||i.owner||'.'||i.table_name;
EXECUTE IMMEDIATE l_sql;
Expand All @@ -580,6 +581,7 @@ BEGIN
, SUBSTR(table_name,-2) length
FROM all_part_tables
WHERE table_name LIKE 'PSTREESELECT__'
AND (owner = 'SYSADM' OR owner like 'NVEXEC%')
) LOOP
l_sql := 'DELETE FROM '||i.owner||'.'||i.table_name
||' WHERE NOT selector_num IN(SELECT selector_num FROM ps_nvs_treeslctlog l WHERE l.ownerid='''||i.owner||''' AND l.length='||i.length||' AND status_flag=''I'')';
Expand Down Expand Up @@ -786,5 +788,15 @@ END xx_nvision_selectors;
/
show errors

EXEC DBMS_UTILITY.compile_schema(schema => 'SYSADM');
BEGIN
FOR i IN (
SELECT username
FROM dba_users
WHERE (username = 'SYSADM' OR username LIKE 'NVEXEC%')
) LOOP
dbms_output.put_line('Compiling:'||i.username);
DBMS_UTILITY.compile_schema(schema => i.username, compile_all=>FALSE);
END LOOP;
END;
/
spool off

0 comments on commit 5a68ca2

Please sign in to comment.