Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: whenever sqlerror is an unknown statement?
On 20 Jan 2006 11:28:38 -0800, jjsavage_at_gmail.com wrote:
>My overall goal is to create a table iff it doesn't exist. After more
>poking around the docs, I've got this:
>
>begin
> select * from all_tables where table_name = 'foo';
You need an INTO clause, even if you don't actually care about the result.
> exception
> when no_data_found then
> begin
> create table foo(bar char(5));
You can't write DDL directly in PL/SQL, you have to wrap it in EXECUTE
IMMEDIATE.
> end;
>end;
>
>Bah! Why can't I have a create, but I can have a select or update or
>anything else?
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/dynamic.htm#CACDDACH
-- Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis toolReceived on Fri Jan 20 2006 - 14:27:47 CST