B'jour la liste,

J'essaie d'implementer un trigger after/before DDL

pour empecher de creer une table avec colonne number (defaut)
et mettre a la place number (n,v)

ex create t1 (col1 number(2,0));

voici

le code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
CREATE OR REPLACE TRIGGER COL_NUM_ALTER
AFTER ALTER
ON SCHEMA
DECLARE
 v_precis user_tab_columns.data_precision%TYPE;
 v_scale  user_tab_columns.data_scale%TYPE;
v_data_type  user_tab_columns.data_type%TYPE;
 x user_tables.table_name%TYPE;
 sql_Text    ORA_NAME_LIST_T;
stmt varchar2(2000);
i pls_integer;
this_col varchar2(100);
 
BEGIN
 SELECT ora_dict_obj_name
  INTO x
  FROM dual;
  i:=ora_sql_txt(sql_text);
   if (ora_sysevent='ALTER') then
	for l in 1..i loop
	stmt := stmt || sql_text(l);
  end loop;
  this_col := REGEXP_SUBSTR(stmt,'[^[:blank:]]+', 1, 5);
 
  dbms_output.put_line('THIS  IS COLUMN :' ||this_col);
 
    for c in (SELECT data_precision,data_scale,data_type,column_name
    	FROM user_tab_columns
	where table_name=x
     and column_name=this_col) loop
 
  dbms_output.put_line('table_name :' ||x ||'- '||c.column_name);
 
	--  if c.column_name = trim(this_col) then
 
      dbms_output.put_line('STILL HAVE COL_NAME :' ||x ||'- '||c.column_name);
	     	IF (c.data_type='NUMBER' and c.data_precision is null ) THEN
    			RAISE_APPLICATION_ERROR(-20099, 'number precision must be not null');
  		  END IF;
  	--	  end if;
 end loop;
  end if;
--EXCEPTION
--when no_data_found then null;
END COL_NUM_ALTER;
/

Mais ca marche pas


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
alter table t3 add col1 number; ==> NE DEVRAIT PAS ETRE AUTORISE
THIS  IS COLUMN :col1
 
Table altered.
 
 alter table t3 add col3 number(3); ==> AUTORISE 
THIS  IS COLUMN :col3
 
Table altered.
Merci d'avance si quelqu'un peut m'aider