Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL query

PL/SQL query

From: <c.raczko_at_usa.net>
Date: Fri, 12 Feb 1999 21:46:41 GMT
Message-ID: <7a27fu$u01$1@nnrp1.dejanews.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US