| 12
 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
 
 |  
create or replace procedure create_tab(n_tab in varchar2) is
v_req varchar2(1000);
v_col varchar2(500);
ttyp varchar2(20);
val varchar2(1);
begin
select nvl(valider,'N') into val  from prm_tabs where nom_tab = n_tab;
--dbms_output.put_line(val);
if val = 'N' then
v_req := 'create table '||n_tab||'(';
-------------------------------------------
----------------------------------------
for c in(select * from prm_cols where nom_tab = n_tab) loop
select decode(c.type_col,'N','NUMBER','V','VARCHAR2','D','DATE','LONG RAW') into ttyp from dual;
v_col :=v_col||c.nom_col||' '||ttyp ;
-------------------------------------------------------------------
if c.type_col = 'N' and c.long_col is not null and c.precis_col is not null then
v_col := v_col||'('||c.long_col||','||c.precis_col||')';
elsif c.type_col = 'N' and c.long_col is not null and c.precis_col is null  then
v_col := v_col||'('||c.long_col||')';
elsif c.type_col = 'V' then 
v_col := v_col||'('||c.long_col||')';
/*else
v_col := v_col||',';*/
end if;
------------------------------------------
v_col := v_col||',';
 end loop;
--------------------------------------------
--------------------------------------------
 v_col := substr(v_col,1,length(v_col)-1);
 v_col := v_col||')';
 v_req := v_req||v_col;
 update prm_tabs set valider = 'O' where nom_tab = n_tab ;
 execute immediate v_req;
 
 end if;
 end; | 
Partager