Viet Anh
Viet Anh

Reputation: 139

using sql script in SQL plus in Oracle 11g

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

Upvotes: 0

Views: 5606

Answers (3)

Dave Costa
Dave Costa

Reputation: 48131

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

Upvotes: 1

Ciarán
Ciarán

Reputation: 3057

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.

Upvotes: 0

Satish
Satish

Reputation: 721

Did you try @filename in the prompt something like

 >@runscript.sql

Upvotes: 0

Related Questions