5

I'm trying to create a PL/SQL script that prints a message and then creates a table.

If I run the script in SqlPlus, the message is printed, the table is created, but I receive an error message saying the table is in use. It seems the "create table" is running twice. In SQLDeveloper I have no errors.

This is my script:

set serveroutput on

begin
  dbms_output.Put_line('running test.sql');
end;
/
create table my_table
(
  name varchar2(100) not null
);
/

This is the output:

SQL> @test.sql
running test.sql

PL/SQL procedure successfully completed.

Table created.

create table my_table
             *
ERROR at line 1:
ORA-00955: name is already used by an existing object    

SQL>

What I'm doing wrong?

Thanks in advance.

Bolha
  • 253
  • 3
  • 8
  • 15
    Your `;/` at the end of the create table will execute the statement twice: http://stackoverflow.com/a/10207695/330315 You only need the `/` for PL/SQL, not for SQL statements. –  Nov 05 '15 at 20:15

1 Answers1

-1

Change you script to this:

set serveroutput on
begin
   dbms_output.Put_line('running test.sql');
   create table my_table
   (
     name varchar2(100) not null
   );
end
/
Sam
  • 404
  • 4
  • 7