• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Creating views by selecting from dba_views - determining the order

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?

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

Thank you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now