Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create or Replace in PL\SQL

Status
Not open for further replies.

cfcProgrammer

Programmer
Mar 1, 2006
88
CA
Hi
I am trying to create a view within a stored proc but I am getting an error while doing this. I have never created a view on the fly within a procedure before... Is this even allowed?

This is the error I am getting:
[COLOR=blue lightblue]
PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:

begin case declare exit for goto if loop mod null pragma
raise return select update while with <an identifier> [/color]

Thank you in advance for your help
cfcProgrammer
 
You can't run DDL commands in native sql without execute immediate. For example

begin
execute immediate create view my_view as select col1,col23 from my_table;
end;




Bill
Oracle DBA/Developer
New York State, USA
 
Er..you might need quotes around it as well:

begin
execute immediate 'create view my_view as select col1,col23 from my_table';
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top