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 -> Re: PL/SQL Problem

Re: PL/SQL Problem

From: Chinna <jchinna_at_enron.com>
Date: 1997/09/16
Message-ID: <01bcc2db$0adfd980$06f7fb9b@eoghou1325.eog.enron.com>#1/1

Here it is:

declare
found_table number;
cursor tab is select count(*) from user_tables where table_name like 'table_name';
begin
found_table :=0;
open tab;
fetch tab into found_table;
if tab%found
then
  if found_table=1
  then

     drop table table_name;
     create table table_name;

  end if;
end if;
close tab;
end;

Let me know if this helped,
Chinna      

Dmitry Babitsky <dimitry_at_ix.netcom.com> wrote in article <01bcba20$8e0cbad0$28ccb7c7_at_dmitry40e>...
> I need to find out in my procedure if a table exists and drop and
 recreate
> it .
> This is how it's done in Transact-SQL(SQL Server):
> IF EXISTS(SELECT * FROM sysobjects where name = my_table) DROP TABLE
> my_table
> .....
> CREATE TABLE my_table
>
> Can anybody help me do it in PL/SQL? Thanks in advance and if you can -
> please e-mail your answer.
>
> --
> Dmitry Babitsky. MCSE, MCSD
>
> dimitry_at_ix.netcom.com
>
Received on Tue Sep 16 1997 - 00:00:00 CDT

Original text of this message

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