I need to build a process that creates tables dynamically.
I have this:
declare
type array is table of varchar2(30) index by binary_integer;
a array;
expression varchar2(2000);
RESUME_create LONG;
procedure createTables ( texto in VARCHAR2 ) is
begin
dbms_output.put_line('the parameter is: ' || texto);
expression := 'begin ' || texto || '; end;';
dbms_output.put_line(expression);
execute immediate expression;
end;
RESUME_create := 'CREATE TABLE RESUME (
R_Resume_date DATE DEFAULT SYSDATE NOT NULL ,
R_Resume_source CHAR(3) DEFAULT ''001'' NOT NULL ,
R_Resume_channel CHAR(3) DEFAULT ''001'' NOT NULL )';
createTables('RESUME_create');
end;
/
So this is just an example.
So imagine that I need to declare multiples CREATE TABLEs and call the createTable into a loop passing multiples string that the function has to evaluate and execute.
codeRESUME_create := 'CREATE TABLE RESUME (R_Resume_Idate NUMBER(3,0) )'; NOTES_create := 'CREATE TABLE RESUME (R_Resume_Idate NUMBER(3,0) )'; ITYPE_create := 'CREATE TABLE RESUME (R_Resume_Idate NUMBER(3,0) )';codeAfter that, into a loop read tablas, concatenate "_create" and evaluate into a execute immediate