Unable to compile package because of a lock

 Issue

You cannot compile a database object because there is a long running job running it. When compiling the statement just hangs.

Solution

(1) Find the culprit.

In my case I was trying to compile a package with the name HOUSE in it

select *
from DBA_DDL_LOCKS
where name like '%HOUSE%';

(2) You should have two rows, one for the locking rocess, ad one for the one which you are using to try and compile.

 select *
 from v$session
 where sid in (140,637) ;--
change to your sessions gained from the above SQL.

 To double check, have a look at the SQL.

 select *
from v$sql
where sql_id = '6fbhqv3m80ghb';


(3) Kill the offending process


   ALTER SYSTEM KILL SESSION '140,32348'; --SID and SERIAL from the previous query.


Your procedure/package/DDL statement will immediately continue..

Comments