I am looking for a way to avoid a recurrent error of mine, working with SQL scripts that sometimes contain PL/SQL blocks. As you may know, in sqlplus
, if you do not add a slash /
after a PL/SQL block (Begin ... End;
), the block is not executed.
But from my development tools, the lack of slash is not detected until my stuff gets deployed on the testing environment, and it adds confusion and stress to the process.
I had this issue in many places I've worked at, and with many tools. So I wonder if it is possible to configure Oracle sqlplus
either to
- execute the content of the "buffer" before commits, even if no
/
is there - raise an error message if "buffer" is not empty when exiting
Another solution would be to change the behaviour of my development tools, I know, but am also looking forward to extend my Oracle knowledge with your permission.
To fix the idea, let's say I deliver script a.sql
, that is encapsulated later on into the company's deployment script dpl.sql
dpl.sql
simplified (note the importance of the .
that kind of hides the issue, but that I cannot change, and is THE thing to work around)
spool dpl.log
@a
.
spool off
a.sql
where I forgot the /
after my pl/Sql block before of personal inconsistency by design (beauty of Nature)
create table a(n number);
begin
dbms_output.put_line('coucou');
end;
insert into a select 1 from dual ;
commit ;
Result where you see no commit, and no error...
SQL> @dpl
Table dropped.
Table created.
SQL> select count(1) from a ;
COUNT(1)
----------
0
I went through these, to no avail: