I have two schema in my Oracle database. The first schema is "STUDENT" schema, that has 4 tables:
- course (id, name, date, master)
- grade (id, course_id, course_name, grade)
- master (id, stu_id, grade)
- detail (id, stu_id, master_id,date)
Also I have another schema that name is "ALLDATA", I have a table in this schema named "table_schema" the structure of this table is like below.(this table only have some of the STUDENT schema s table s name.)
id table_name
---------- ----------
1 course
2 grade
3 master
I have another table named view_schema:
enter code here
id schema_name
---------- ----------
1 STUDENT
I want to write a procedure in ALLDATA schema that loop on "table_schema" and create view for the tables name from STUDENT schema. Actually I want my procedure to do something like below:
create or replace PROCEDURE VIEWINSTRACTOR
is
begin
for j in (select SCHEMA_NAME from ALLDATA.VIEW_SCHEMA)
loop
for i in (select table_name from ALLDATA.VIEW_TABLE)
loop
execute immediate 'create or replace view ALLDATA.'|| i.table_name
||' as select * from '|| j.SCHEMA_NAME.i.table_name;
end loop;
end loop;
end;
but I got errors.