|
|
|
|
|
|
|
|
Re:How to apply restriction on trigger of Alter [message #304755 is a reply to message #304548] |
Thu, 06 March 2008 08:54 |
MIFI
Messages: 256 Registered: February 2008 Location: U.K.
|
Senior Member |
|
|
CREATE OR REPLACE TRIGGER ALTER_trigger
BEFORE ALTER ON <SCHEMA NAME>.SCHEMA
declare
sql_text ora_name_list_t;
v_stmt VARCHAR2(2000);
v_t varchar2(100);
v_t2 varchar2(100);
n number;
BEGIN
n := ora_sql_txt(sql_text);
FOR i IN 1..n LOOP
v_stmt := v_stmt || sql_text(i);
END LOOP;
select SUBSTR(v_stmt,INSTR(v_stmt,'drop column',1),11) into v_t from dual;
if v_t='drop column' then
RAISE_APPLICATION_ERROR (
num => -20000,
msg => 'Cannot Alter table');
ELSE
select SUBSTR(v_stmt,INSTR(v_stmt,'rename column',1),13) into v_t from dual;
if v_t='rename column' then
RAISE_APPLICATION_ERROR (
num => -20000,
msg => 'Cannot Alter table');
end if;
end if;
END;
|
|
|
|
Re:How to apply restriction on trigger of Alter [message #304786 is a reply to message #304769] |
Thu, 06 March 2008 11:32 |
MIFI
Messages: 256 Registered: February 2008 Location: U.K.
|
Senior Member |
|
|
Thank you very much, i have changed my trigger as follows
CREATE OR REPLACE TRIGGER ALTER_trigger
BEFORE ALTER ON <SCHEMA NAME>.SCHEMA
declare
sql_text ora_name_list_t;
v_stmt VARCHAR2(2000);
v_t varchar2(100);
n number;
BEGIN
n := ora_sql_txt(sql_text);
FOR i IN 1..n LOOP
v_stmt := v_stmt || sql_text(i);
END LOOP;
if INSTR(lower(v_stmt),'drop column',1)<>0 OR INSTR(lower(v_stmt),'rename column',1)<>0 then
RAISE_APPLICATION_ERROR (
num => -20000,
msg => 'Cannot Alter table');
end if;
END;
|
|
|
|
Re:How to apply restriction on trigger of Alter [message #304937 is a reply to message #304789] |
Fri, 07 March 2008 04:35 |
MIFI
Messages: 256 Registered: February 2008 Location: U.K.
|
Senior Member |
|
|
CREATE OR REPLACE TRIGGER ALTER_trigger
BEFORE ALTER ON <schemaname>.SCHEMA
declare
sql_text ora_name_list_t;
v_stmt VARCHAR2(2000);
v_t varchar2(100);
n number;
BEGIN
n := ora_sql_txt(sql_text);
FOR i IN 1..n LOOP
v_stmt := v_stmt || sql_text(i);
END LOOP;
if INSTR(lower(v_stmt),'drop column',1)<>0 OR INSTR(lower(v_stmt),'rename column',1)<>0
OR INSTR(lower(v_stmt),'set unused',1)<>0 OR INSTR(lower(v_stmt),'drop unused',1)<>0
OR INSTR(lower(v_stmt),'modify',1)<>0
then
RAISE_APPLICATION_ERROR (
num => -20000,
msg => 'Cannot Alter table');
end if;
END;
|
|
|