-
Notifications
You must be signed in to change notification settings - Fork 2
/
pstreeselctl.sql
51 lines (48 loc) · 1.47 KB
/
pstreeselctl.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
REM pstreeselctl.sql
spool pstreeselctl append
CREATE TABLE &&1..PSTREESELCTL (SETID VARCHAR2(5) NOT NULL,
SETCNTRLVALUE VARCHAR2(20) NOT NULL,
TREE_NAME VARCHAR2(18) NOT NULL,
EFFDT DATE NOT NULL,
VERSION INTEGER NOT NULL,
SELECTOR_NUM INTEGER NOT NULL,
SELECTOR_DT DATE NOT NULL,
TREE_ACC_SEL_OPT VARCHAR2(1) NOT NULL,
LENGTH SMALLINT NOT NULL)
TABLESPACE PTWORK
STORAGE (INITIAL 40000 NEXT 100000 MAXEXTENTS UNLIMITED PCTINCREASE 0)
PCTFREE 10 PCTUSED 80
/
CREATE UNIQUE iNDEX &&1..PS_PSTREESELCTL ON &&1..PSTREESELCTL (SETID,
SETCNTRLVALUE,
TREE_NAME,
EFFDT /*DESC*/)
TABLESPACE PSINDEX
STORAGE (INITIAL 40000 NEXT 100000 MAXEXTENTS UNLIMITED PCTINCREASE 0)
PCTFREE 10 PARALLEL NOLOGGING
/
ALTER INDEX &&1..PS_PSTREESELCTL NOPARALLEL LOGGING
/
GRANT SELECT, INSERT, UPDATE, DELETE ON pstreeselctl TO &&1.;
CREATE OR REPLACE TRIGGER &&1..xx_pstreeselctl_inc
AFTER INSERT OR UPDATE OR DELETE ON &&1..pstreeselctl
FOR EACH ROW
BEGIN
IF deleting THEN
UPDATE &&1..ps_nvs_treeslctlog
SET status_flag = 'D'
, tree_name = :old.tree_name
WHERE selector_num = :old.selector_num
AND ownerid = '&&1.'
AND status_flag = 'S';
ELSE
UPDATE &&1..ps_nvs_treeslctlog
SET status_flag = 'S'
, tree_name = :new.tree_name
WHERE selector_num = :new.selector_num
AND ownerid = '&&1.';
END IF;
EXCEPTION WHEN OTHERS THEN NULL; --exception deliberately coded to suppress all exceptions
END;
/
spool off