Megacan
Megacan

Reputation: 2518

SqlPlus not terminating sql script

I have a file with the folowing script:

BEGIN
    ...
    a bunch of inserts
    ...
    COMMIT;

EXCEPTION
    WHEN OTHERS THEN ROLLBACK;
END;

When I execute this in sqlplus I get the following:

SQL> @file.sql
382

It's as if he's not ending the block. I'm new to using pl/sql and sqlplus, so I don't know if I'm doing something wrong.

Any ideas?

Upvotes: 7

Views: 10725

Answers (2)

Megacan
Megacan

Reputation: 2518

Ok, I figured it out. I should have search better in the documentation before posting the question here.

Anyway according to this link: http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/ch4.htm#sthref840

SQL*Plus treats PL/SQL subprograms in the same manner as SQL commands, except that a semicolon (;) or a blank line does not terminate and execute a block. Terminate PL/SQL subprograms by entering a period (.) by itself on a new line. You can also terminate and execute a PL/SQL subprogram by entering a slash (/) by itself on a new line.

Instead of END you must finish with /.

Upvotes: 0

Tony Andrews
Tony Andrews

Reputation: 132710

You need to add one more line after the final END; like this:

/

Just a slash as the first character on the line, and then a new line.

Upvotes: 12

Related Questions