Solved

SqlPlus script fails to create objects

Posted on 2011-09-18
6
528 Views
Last Modified: 2012-05-12
New to Oracle and SqlPlus, I need to create a release script for an exising set of files for tables/views/functions/etc.  I'm finding that unlike Toad, when SqlPlus processes these files, the objects are not created if the file does not end with "/".  I can ask that all the files be corrected, but I thought there might be some SqlPlus option that handles this.  Is there any way around this in SqlPlus?
0
Comment
Question by:jkavx
6 Comments
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 36557883
- apart from using '/' you can put semicolon ';'at the end of each statement in your script to execute each of the sql statements.

- eg:
select * from o_table1;
create table table2 as select * from table1;
0
 

Author Comment

by:jkavx
ID: 36557948
These are ddl scripts.  One script per object - table, view, function, procedure.  The problem files end with ";" but without a final line with "/", the SqlPlus commands, although successful, don't actually create the object.
0
 
LVL 23

Expert Comment

by:OP_Zaharin
ID: 36558088
- i've done my test on the following script without having to use slash '/':
- my script contain:
CREATE TABLE "TEST"."TEST2"
   (      "LEGACYKEY" VARCHAR2(100),
      "CODE" VARCHAR2(10),
      "CODE2" VARCHAR2(10),
      "CODE3" VARCHAR2(10)
   );

- and i execute it this way:
SQL> @c:\temp\test2.sql;

Table created.

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 23

Accepted Solution

by:
OP_Zaharin earned 500 total points
ID: 36558089
- kindly note also that if you are executing pl/sq block, you need to use slash '/' as mention in the Oracle doc:

"You must include a semicolon at the end of each SQL command and a slash (/) on a line by itself after each PL/SQL block in the file. You can include multiple SQL commands and PL/SQL blocks in a script"
http://download.oracle.com/docs/cd/B14117_01/server.101/b12170/ch6.htm
0
 
LVL 6

Expert Comment

by:tangchunfeng
ID: 36558289
$ cat a.sql
select count(*) from dual
/
exit

$ sqlplus scott/tiger @a.sql


  COUNT(*)
----------
         1

This works.
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36559675
Check for blank lines.

The semi-colon (';') MUST be at the end of the command immediately on the next line.

The slash ('/') tells sqlplus to run whatever comment is current in the buffer.  With only one command per script a blank line after the command will store the script in the command buffer and a '/' will execute it later.

I don't like this idea since each script should be able to execute by itself but since you asked it there was a way around it:  If you have some master script that calls them individually you can always add the '/' in the master script after the individual ones.

master.sql
-------
@file1
/

@file2
/

etc...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now