Home > Database > Mysql Tutorial > Oracle dbms_lock.sleep()存储过程使用技巧-场景-分析-实例

Oracle dbms_lock.sleep()存储过程使用技巧-场景-分析-实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:36:31
Original
2663 people have browsed it

《Oracledbms_lock.sleep()存储过程使用技巧》-场景-分析-实例摘要:今天是2014年3月10日,北京,雾霾,下午组织相关部门开会。会议的结尾一名开发工程师找到了

.sleep()

例如:DBMS_LOCK.SLEEP(1.95);是一个合法的值


Example

1)由于是一个存储过程可以直接使用

SQL> executedbms_lock.sleep(60);

PL/SQL procedure successfullycompleted

SQL> select * frompb_tradeinfo where rownum

IID       TRADEID       NAME          CERTTYPE

------------------------------------------ ----------------------------------

382       548          一次性还款          0

415       563          测试一次性贷款      2

423       569          测试                1


2PL/SQL块实现延迟60

SQL> begin

 2 dbms_output.put_line(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));

 3 dbms_lock.sleep(60);

 4 dbms_output.put_line(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'));

 5  end;

 6  /


2014-03-1020:41:56

2014-03-1020:42:56


PL/SQL procedure successfullycompleted


3)打印间隔5秒时间列表

创建测试表

SQL> create tableleonarding (iid number,appendtime date);

Table created

开始测试

SQL> begin

 2      for i in 1..10

 3      loop

 4          insert into leonarding values(i,sysdate);

 5          commit;

 6          dbms_lock.sleep(5);

 7       end loop;

 8  end;

 9  /

PL/SQL procedure successfullycompleted

打印列表

SQL> select * fromleonarding;

      IID APPENDTIME

------------------------------------------------------------

        1 2014-3-10 20:51:20

        2 2014-3-10 20:51:25

        3 2014-3-10 20:51:30

        4 2014-3-10 20:51:35

        5 2014-3-10 20:51:40

        6 2014-3-10 20:51:45

        7 2014-3-10 20:51:50

        8 2014-3-10 20:51:55

        9 2014-3-10 20:52:00

       10 2014-3-10 20:52:05

10 rows selected

小结:dbms_lock.sleep()过程我们在使用的时候请注意第一是权限要授予,第二是使用的场景,第三注意单位。


dbms  sleep   延迟   package   leonarding


Leonarding 刘盛

2014.03.10

北京&spring

分享技术~成就梦想

Blog






本文出自 “刘盛分享技术~成就梦想” 博客,,请务必保留此出处

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template