码迷,mamicode.com
首页 > 数据库 > 详细

Oracle EBS 加锁解锁程序

时间:2018-11-23 14:05:49      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:arch   lease   log   bsp   locate   数据   else   com   uniq   

  FUNCTION request_lock(p_lock_name IN VARCHAR2) RETURN BOOLEAN IS
    l_lock_name   VARCHAR2(128);
    l_lock_ret    INTEGER;
    l_ret_val     BOOLEAN := TRUE;
    l_lock_handle VARCHAR2(240);
  BEGIN
    IF p_lock_name IS NOT NULL THEN
      --增加数据库锁,以保证一个批次同时只运行一次
      l_lock_name := p_lock_name;
      dbms_lock.allocate_unique(lockname   => l_lock_name,
                                lockhandle => l_lock_handle);
      g_lock_handle := l_lock_handle;
      --获取数据库锁
      l_lock_ret := dbms_lock.request(lockhandle        => l_lock_handle,
                                      lockmode          => 6,
                                      timeout           => 10,
                                      release_on_commit => FALSE);
      IF l_lock_ret <> 0 THEN
        --状态不为(成功)
        l_ret_val := FALSE;
      END IF;
    ELSE
      l_ret_val := FALSE;
    END IF;
    cux_conc_utl.log_msg(request lock);
    RETURN l_ret_val;
  END request_lock;
 PROCEDURE release_lock(p_lock_name IN VARCHAR2) IS
    l_lock_name   VARCHAR2(128);
    l_lock_handle VARCHAR2(128);
    l_lock_ret    INTEGER;
  BEGIN
    IF g_lock_handle IS NOT NULL THEN
      l_lock_ret := dbms_lock.release(g_lock_handle);
    ELSE
      l_lock_name := p_lock_name;
      dbms_lock.allocate_unique(lockname   => l_lock_name,
                                lockhandle => l_lock_handle);
      l_lock_ret    := dbms_lock.release(l_lock_handle);
      g_lock_handle := l_lock_handle;
    END IF;
    cux_conc_utl.log_msg(release_lock:  || l_lock_ret);
  END release_lock;

 

Oracle EBS 加锁解锁程序

标签:arch   lease   log   bsp   locate   数据   else   com   uniq   

原文地址:https://www.cnblogs.com/jenrry/p/10006867.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!