Solved

SqlPlus script fails to create objects

Posted on 2011-09-18
6
547 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

724 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