function get_pid() #the head locked process id {
pid=`${SQLPLUS}-S ${ORACLE_USERNAME}<<\EOF
set head off
select v2.spid from v$session v1, v$process v2
where v1.paddr = v2.addr and v1.sid in(select v3.SESSION_ID from v$locked_object v3
where v3.oracle_username = user);
EOF
` }
function kill_session() #kill the head locked session {
${SQLPLUS} ${ORACLE_USERNAME}<< \EOF
DECLARE
v_sid int;
v_serial int;
BEGIN
select v1.sid, v1.serial#
into v_sid, v_serial from v$session v1, v$process v2
where v1.paddr = v2.addr and v1.sid in(select v3.SESSION_ID from v$locked_object v3
where v3.oracle_username = user);
if v_sid isnot null and v_serial isnot null then
execute immediate 'alter system kill session '||''''|| v_sid ||','||
v_serial ||'''';
end if;
END; /
EOF }