Creating views by selecting from dba_views - determining the order

Posted on 2007-10-18
Medium Priority
Last Modified: 2013-12-07
I want to create views in a schema, based on views in another schema.
This is the code:
(USER2 already has the tables in it's schema)
cursor c_views(cp_username in varchar2) is
select  view_name,  text
from dba_views
where owner = cp_username;

    for view_row in c_views ('USER1') loop
        create_string := 'create view USER2.||view_row.view_name||' as '||view_row.text||' ';
        execute immediate create_string;
    end loop;
All this works fine, but my problem is that some of the views are based on other views that haven't been created yet, so I get an error "Table or View doesn't exist". Therefore I need to create the views in the right order.

Any ideas on how to do that?

Question by:Mamarazzi

Accepted Solution

konektor earned 1500 total points
ID: 20100204

Author Comment

ID: 20100458
My God! Some of you guys are quick! And the question was a real RTFM!!! I feel ashamed... :-)

Thank you!

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses
Course of the Month17 days, 12 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question