Ask Experts Questions for FREE Help !
Ask
    canton07's Avatar
    canton07 Posts: 2, Reputation: 1
    New Member
     
    #1

    Nov 27, 2008, 02:15 PM
    Execute immediate 'create table' in script
    My oracle version is 10.2.0.3.0.

    In Toad I have no problem
    1) to create table trg_farinvc as select
    2) select * from all_objects where object_name like 'TRG_FARINVC%'
    3) drop table TRG_FARINVC PURGE
    3) create table trg_farinvc as select --> create table again no problem.
    4) drop table TRG_FARINVC PURGE --> everything is good so far.

    My script run via sqlplus:
    Declare
    ...
    Begin
    Execute immediate 'CREATE TABLE trg_farinvc as select... ';
    End;
    .
    /
    Run
    PROBLEM:
    ORA-00955: name is already used by an existing object

    BUT THE TABLE was already purged in TOAD prior running this script.

    Thanks,
    Trang
    ordba's Avatar
    ordba Posts: 11, Reputation: 1
    New Member
     
    #2

    Dec 8, 2008, 05:00 PM

    SQL> create table testing_tbl1 as select * from testing_tbl;

    Table created.

    SQL> select table_name from user_tables where table_name like 'TESTING%';

    TABLE_NAME
    ------------------------------
    TESTING_TBL
    TESTING_TBL1

    2 rows selected.

    SQL> drop table testing_tbl1 purge;

    Table dropped.

    SQL> select table_name from user_tables where table_name like 'TESTING%';

    TABLE_NAME
    ------------------------------
    TESTING_TBL

    1 row selected.

    SQL> declare
    2 begin
    3 execute immediate 'create table testing_tbl1 as select * from testing_tbl';
    4 end;
    5 /

    PL/SQL procedure successfully completed.

    SQL> select table_name from user_tables where table_name like 'TESTING%';

    TABLE_NAME
    ------------------------------
    TESTING_TBL
    TESTING_TBL1

    2 rows selected.

    SQL>

    Does this help ?
    ordba's Avatar
    ordba Posts: 11, Reputation: 1
    New Member
     
    #3

    Dec 8, 2008, 05:03 PM

    Run this before you execute Statement from SQL*Plus

    Select owner,table_name from all_tables where table_name like 'TRG_FARINVC%' ;

    Show user

    Are you connecting as same user from TOAD and SQL*Plus ?
    canton07's Avatar
    canton07 Posts: 2, Reputation: 1
    New Member
     
    #4

    Dec 9, 2008, 08:05 AM
    Thank you for answering my question. I should not put "run" which call the program again and create a table again.

    Trang

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Can I create records with OLE objects in Access & append to a linked SQLServer table? [ 2 Answers ]

There's a table in our SQL Server Database that stores various notes. There are text fields for the type of notation ( i.e. C = Customer, V=Vendor notes etc) and one for the "Owner_ID" (ie the Customer ID or Vendor ID). There's a date field for the create date of the note and the notes themselves...

Which table to create main form [ 3 Answers ]

I have created the following tables per a response from Scottgem at to another user asking about creating a Access Database for a survey. My database has 26 questions with answers range being not very true to verry true with a couple simple yes no answers. Where I am stumped is how to display...

I am trying to execute form even in JUNIT and it not working [ 1 Answers ]

I am writing junit code to adobe life cycle form and code needed me to added a JS code to activate the drop down liste. so I have added code as listed below. formTester.setFieldValue(this._ddl63d, "Yes"); formTester.executeJavaScript("xfa.form.form1.sfPart3.ddl63d.execEvent(\"change\")"); ...

I cannot execute any hyperlinks on the Internet [ 2 Answers ]

I am running WinXP Home Ed. with IE 7 Just recently this has been happening. When I am at a website and I click on a hyperlink to take me to another site.............I am stuck where I was and I see a red circle with the prohibited line through it. Could this be a bug or spywear of some sort?...

Execute DOS Commands Secretely? [ 2 Answers ]

HELLO THERE! (I'm Using Windows-XP SP-2) I Start With Example: -I Have A Calc.exe -I Rename Calc.exe As Clock.txt -(To Hide Its Identity No Body Knows It's an exe) -Now We Have Clock.txt Kept On C:\ -I Want To Run A Sequence Of DOS Commands. They Are:


View more questions Search