0

I want to import an sql script file to SQL Plus. I found an example and tried following it like this:

SQL>START z:myscript.sql

but it didn't work. The SQL Plus windows just displayed "35" and highlighted the cursor, indicating that I could continue typing (???)

1
  • 1
    What does it mean to "import a SQL script file to SQLPlus"? Are you trying to execute a script using SQLPlus? Commented Jan 15, 2013 at 18:24

3 Answers 3

1

Every statement that creates a code object (e.g. CREATE PROCEDURE, CREATE FUNCTION, CREATE PACKAGE, CREATE TYPE) needs to have a slash ("/") following it in order to execute. Normal SQL statements will execute if terminated with a semicolon, but since lines of PL/SQL code always end with a semicolon, this can't be used as an indicator to execute for code objects.

From your own followup, it sounds like you have multiple such statements in the script, and just entered the slash after the final one. This causes SQLPlus to try to execute the entire text of the script as a single statement, which is likely to fail.

You want something like:

CREATE TYPE my_type_1
  ... your code here ...
/

CREATE TYPE my_type_2
  ... your code here ...
/
Sign up to request clarification or add additional context in comments.

1 Comment

@VietAnh: Dave is corret, but to be precise: every statement that contains an embedded ; needs a slash. So a (simple) CREATE TYPE could be written with a semicolon instead of slash. What's more, the slash is not a simple "replacement" for the ; it does something fundamentally different in SQL*Plus. See here for a more detailed explanation: stackoverflow.com/a/10207695/330315
0

Did you try @filename in the prompt something like

 >@runscript.sql

1 Comment

also runscript.sql should be the same directory where you are starting sqlplus.
0

From the command line, type

 SQLPLUS username/password@TNSNAME @myscript.sql

This will connect to TNSNAME using the specified username and password and execute the myscript.sql file. The script name can be in double quotes if it includes spaces.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.