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 (???)

Viet Anh
  • 139
  • 3
  • 6
  • 16
  • 1
    What does it mean to "import a SQL script file to SQL*Plus"? Are you trying to execute a script using SQL*Plus? – Justin Cave Jan 15 '13 at 18:24

3 Answers3

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 ...
/
Dave Costa
  • 47,262
  • 8
  • 56
  • 72
  • @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: http://stackoverflow.com/a/10207695/330315 –  Jan 15 '13 at 22:32
0

Did you try @filename in the prompt something like

 >@runscript.sql
Satish
  • 713
  • 1
  • 5
  • 18
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.

Ciarán
  • 3,017
  • 1
  • 16
  • 20