CREATE OR REPLACE PACKAGE PCK_LOCK AS 

v_lockhandle varchar2(100);

procedure request(p_lock_name varchar2);

procedure release;

END PCK_LOCK;
/


CREATE OR REPLACE PACKAGE BODY PCK_LOCK AS

  procedure request(p_lock_name varchar2) AS
  v_ret integer;  
  BEGIN
    DBMS_LOCK.ALLOCATE_UNIQUE (
      p_lock_name,
      v_lockhandle      
      );
    
    v_ret := DBMS_LOCK.REQUEST(   
      lockhandle => v_lockhandle,
      timeout    => 1,
      release_on_commit => true);
    
    dbms_output.put_line(v_ret);     
      
  END request;

  procedure release AS
  v_ret integer;
  BEGIN
    v_ret := DBMS_LOCK.RELEASE(   
      lockhandle => v_lockhandle
    );
  END release;

END PCK_LOCK;
/