Creating views by selecting from dba_views - determining the order

Posted on 2007-10-18
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
    LVL 9

    Accepted Solution


    Author Comment

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

    Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Suggested Solutions

    Title # Comments Views Activity
    jobsrunning 3 55
    Oracle 12c 10 83
    Calculating percentages per course - Oracle Query 3 0
    Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
    Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
    This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now