Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL query
I'm in the process of translating some SQL from SQL Server to Oracle and have
had very little luck with the following simple statement:
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'sometable')
DROP TABLE sometable
The simplest way of replicating this functionality that I found involves using PL/SQL, exceptions and cursors:
DECLARE
cursor_name INTEGER;
BEGIN
cursor_name := dbms_sql.open_cursor;
dbms_sql.parse(cursor_name, 'DROP TABLE sometable', dbms_sql.v7);
dbms_sql.close_cursor(cursor_name);
EXCEPTION
WHEN OTHERS THEN NULL;
END;
Surely there must be an easier way? Any help greatly appreciated.
Cezary
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Feb 12 1999 - 15:46:41 CST