1. <legend id='6MyiS'><style id='6MyiS'><dir id='6MyiS'><q id='6MyiS'></q></dir></style></legend>
  2. <i id='6MyiS'><tr id='6MyiS'><dt id='6MyiS'><q id='6MyiS'><span id='6MyiS'><b id='6MyiS'><form id='6MyiS'><ins id='6MyiS'></ins><ul id='6MyiS'></ul><sub id='6MyiS'></sub></form><legend id='6MyiS'></legend><bdo id='6MyiS'><pre id='6MyiS'><center id='6MyiS'></center></pre></bdo></b><th id='6MyiS'></th></span></q></dt></tr></i><div id='6MyiS'><tfoot id='6MyiS'></tfoot><dl id='6MyiS'><fieldset id='6MyiS'></fieldset></dl></div>
      <bdo id='6MyiS'></bdo><ul id='6MyiS'></ul>
      <tfoot id='6MyiS'></tfoot>

    1. <small id='6MyiS'></small><noframes id='6MyiS'>

      ORACLE 中的睡眠功能

      Sleep function in ORACLE(ORACLE 中的睡眠功能)
      <tfoot id='6BpKr'></tfoot>
      • <i id='6BpKr'><tr id='6BpKr'><dt id='6BpKr'><q id='6BpKr'><span id='6BpKr'><b id='6BpKr'><form id='6BpKr'><ins id='6BpKr'></ins><ul id='6BpKr'></ul><sub id='6BpKr'></sub></form><legend id='6BpKr'></legend><bdo id='6BpKr'><pre id='6BpKr'><center id='6BpKr'></center></pre></bdo></b><th id='6BpKr'></th></span></q></dt></tr></i><div id='6BpKr'><tfoot id='6BpKr'></tfoot><dl id='6BpKr'><fieldset id='6BpKr'></fieldset></dl></div>

            <bdo id='6BpKr'></bdo><ul id='6BpKr'></ul>
                <tbody id='6BpKr'></tbody>
            • <legend id='6BpKr'><style id='6BpKr'><dir id='6BpKr'><q id='6BpKr'></q></dir></style></legend>

              <small id='6BpKr'></small><noframes id='6BpKr'>

                本文介绍了ORACLE 中的睡眠功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要在 ORACLE 中执行 SQL 查询需要一定的时间.所以我写了这个函数:

                I need execute an SQL query in ORACLE it takes a certain amount of time. So I wrote this function:

                CREATE OR REPLACE FUNCTION MYSCHEMA.TEST_SLEEP
                (
                TIME_  IN  NUMBER
                )
                RETURN INTEGER IS
                 BEGIN
                   DBMS_LOCK.sleep(seconds => TIME_);
                RETURN 1;
                 EXCEPTION
                   WHEN OTHERS THEN
                   RAISE;
                   RETURN 1;
                END TEST_SLEEP;
                

                我就是这样调用的

                SELECT TEST_SLEEP(10.5) FROM DUAL
                

                但为了工作,我需要将 DBMS_LOCK 设置授予过程的所有者.

                but to work I need set grant of DBMS_LOCK to the owner of the procedure.

                如何在不使用 DBMS_LOCK.sleep 函数的情况下重写此函数?

                How I can rewrite this function without using the DBMS_LOCK.sleep function?

                推荐答案

                如果没有授予对 DBMS_LOCK.sleep 的访问权限,这会起作用,但这是一个可怕的黑客:

                Short of granting access to DBMS_LOCK.sleep, this will work but it's a horrible hack:

                IN_TIME INT; --num seconds
                v_now DATE;
                
                -- 1) Get the date & time 
                SELECT SYSDATE 
                  INTO v_now
                  FROM DUAL;
                
                -- 2) Loop until the original timestamp plus the amount of seconds <= current date
                LOOP
                  EXIT WHEN v_now + (IN_TIME * (1/86400)) <= SYSDATE;
                END LOOP;
                

                这篇关于ORACLE 中的睡眠功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Oracle PL/SQL - Raise User-Defined Exception With Custom SQLERRM(Oracle PL/SQL - 使用自定义 SQLERRM 引发用户定义的异常)
                Oracle: is there a tool to trace queries, like Profiler for sql server?(Oracle:是否有跟踪查询的工具,例如用于 sql server 的 Profiler?)
                SELECT INTO using Oracle(使用 Oracle SELECT INTO)
                How to handle Day Light Saving in Oracle database(如何在 Oracle 数据库中处理夏令时)
                PL/SQL - Use quot;Listquot; Variable in Where In Clause(PL/SQL - 使用“列表Where In 子句中的变量)
                Oracle: Import CSV file(Oracle:导入 CSV 文件)

                <small id='Z7pGY'></small><noframes id='Z7pGY'>

                  <bdo id='Z7pGY'></bdo><ul id='Z7pGY'></ul>

                        <tbody id='Z7pGY'></tbody>
                      <tfoot id='Z7pGY'></tfoot>
                      <legend id='Z7pGY'><style id='Z7pGY'><dir id='Z7pGY'><q id='Z7pGY'></q></dir></style></legend>

                      1. <i id='Z7pGY'><tr id='Z7pGY'><dt id='Z7pGY'><q id='Z7pGY'><span id='Z7pGY'><b id='Z7pGY'><form id='Z7pGY'><ins id='Z7pGY'></ins><ul id='Z7pGY'></ul><sub id='Z7pGY'></sub></form><legend id='Z7pGY'></legend><bdo id='Z7pGY'><pre id='Z7pGY'><center id='Z7pGY'></center></pre></bdo></b><th id='Z7pGY'></th></span></q></dt></tr></i><div id='Z7pGY'><tfoot id='Z7pGY'></tfoot><dl id='Z7pGY'><fieldset id='Z7pGY'></fieldset></dl></div>