This can't be done without some kind of workaround, so here's one for you.
You can recompile the PL/SQL after creation & raise an exception if the recompilation fails. This will cause SQL*Plus to exit on failure.
For example:
test.sql:
create or replace procedure foo
as
begin
this is an error;
end;
/
exec execute immediate 'alter procedure foo compile'; exception when others then raise_application_error(-20000,'compilation error')
Example:
[oracle@node1 ~]$ sqlplus phil/phil
SQL*Plus: Release 11.2.0.2.0 Production on Fri Dec 14 20:45:47 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> WHENEVER SQLERROR EXIT SQL.SQLCODE
SQL> @test.sql
Warning: Procedure created with compilation errors.
BEGIN execute immediate 'alter procedure foo compile'; exception when others then raise_application_error(-20000,'compilation error'); END;
*
ERROR at line 1:
ORA-20000: compilation error
ORA-06512: at line 1
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@node1 ~]$