开发者

SqlPlus not terminating sql script

开发者 https://www.devze.com 2022-12-20 22:21 出处:网络
I have a file with the folowing script: BEGIN ... a bunch of inserts ... COMMIT; EXCEPTION WHEN OTHERS THEN ROLLBACK;

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?


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消