?
Solved

SqlPlus script fails to create objects

Posted on 2011-09-18
6
Medium Priority
?
555 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 23

Accepted Solution

by:
OP_Zaharin earned 2000 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 77

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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