DECLARE v_lockhandle VARCHAR2(200);
v_RET INTEGER;

BEGIN

  -- INIZIO TEST LOCK
  IF v_lockhandle IS NULL THEN
     dbms_lock.allocate_unique('LOCK_MOV', v_lockhandle);
  END IF;
  
  IF dbms_lock.request(v_lockhandle, dbms_lock.x_mode, 0) != 0 THEN
    SP_INS_LOG_ERROR(v_DS_PROC, 0, 'Procedura gia'' in uso [LOCK]', null, 'system', 'N', 
'ORACLE');
    RETURN;
  END IF;
  -- FINE TEST LOCK
  
  -- LINE 1 --
  -- LINE 2 --
  -- LINE N --

  -- RELEASE LOCK
  v_RET := dbms_lock.release(v_lockhandle);
  

END;