Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6770469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:18:57+00:00 2026-05-26T15:18:57+00:00

2 Separate questions. I am using this script to drop a table [SOLVED] BEGIN

  • 0

2 Separate questions.

  1. I am using this script to drop a table [SOLVED]

    BEGIN
        EXECUTE IMMEDIATE 'DROP TABLE_NAME';
        DBMS_OUTPUT.PUT_LINE ('Global table TABLE_NAME Dropped');
        EXCEPTION
            WHEN OTHERS THEN
                DBMS_OUTPUT.PUT_LINE ('Global table TABLE_NAME Doesn''t exist.');
    END;
    /
    

Is there anyway I can differentiate if table “doesn’t exist” or it is being used in some other sessions (in that case it would locked and couldn’t be deleted). I am not sure if I can see that table exists in user_tables. I am not fully aware of permissions.

I have added this code now

WHEN OTHERS THEN
        i_code  :=  SQLCODE;
        v_errm  :=  SUBSTR(SQLERRM, 1, 64);
  if i_code = -942 THEN
    DBMS_OUTPUT.PUT_LINE ('TABLE_NAME doesn''t exist. Script will continue to create it');
  ELSE
    DBMS_OUTPUT.PUT_LINE ('Error dropping temporary table. The error code is ' || i_code || '- ' || v_errm);
  END IF ;

2. I see . at the end of each procedure like this

END PROCEDURE_NAME;
.
/
sho err;

I just don’t understand why . is here. Is it syntax or what?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:18:57+00:00Added an answer on May 26, 2026 at 3:18 pm

    Step 1. Figure out which errors you want to trap:

    If the table does not exist:

    SQL> drop table x;
    drop table x
               *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    

    If the table is in use:

    SQL> create global temporary table t (data varchar2(4000));
    
    Table created.
    

    Use the table in another session. (Notice no commit or anything after the insert.)

    SQL> insert into t values ('whatever');
    
    1 row created.
    

    Back in the first session, attempt to drop:

    SQL> drop table t;
    drop table t
               *
    ERROR at line 1:
    ORA-14452: attempt to create, alter or drop an index on temporary table already in use
    

    So the two errors to trap:

    1. ORA-00942: table or view does not exist
    2. ORA-14452: attempt to
      create, alter or drop an index on temporary table already in use

    See if the errors are predefined. They aren’t. So they need to be defined like so:

    create or replace procedure p as
        table_or_view_not_exist exception;
        pragma exception_init(table_or_view_not_exist, -942);
        attempted_ddl_on_in_use_GTT exception;
        pragma exception_init(attempted_ddl_on_in_use_GTT, -14452);
    begin
        execute immediate 'drop table t';
    
        exception 
            when table_or_view_not_exist then
                dbms_output.put_line('Table t did not exist at time of drop. Continuing....');
    
            when attempted_ddl_on_in_use_GTT then
                dbms_output.put_line('Help!!!! Someone is keeping from doing my job!');
                dbms_output.put_line('Please rescue me');
                raise;
    end p;
    

    And results, first without t:

    SQL> drop table t;
    
    Table dropped.
    
    SQL> exec p;
    Table t did not exist at time of drop. Continuing....
    
    PL/SQL procedure successfully completed.
    

    And now, with t in use:

    SQL> create global temporary table t (data varchar2(4000));
    
    Table created.
    

    In another session:

    SQL> insert into t values (null);
    
    1 row created.
    

    And then in the first session:

    SQL> exec p;
    Help!!!! Someone is keeping from doing my job!
    Please rescue me
    BEGIN p; END;
    
    *
    ERROR at line 1:
    ORA-14452: attempt to create, alter or drop an index on temporary table already in use
    ORA-06512: at "SCHEMA_NAME.P", line 16
    ORA-06512: at line 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(creating a separate question after comments on this: Javascript redeclared global variable overrides old
There are questions pertaining to reading settings from a separate config file and others
I´m trying to separate a gridViewColumn into two rows. Im using default style for
Scenario 1 This involves using one gateway route in app.yaml and then choosing the
Edit: As Andrew Moore pointed out this question is a duplicate of Two separate
Without using a WebBrowser control, how could I execute a JavaScript function, that is
I am using a JavaScript script that tells me if specific image URLs are
I'm trying to wrap my head around this. My language is Java using PlayFramework
I am bringing out a separate question from here . It really confused me.
QUESTION: How can I handle potential contention between two separate threads accessing the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.