<bdo id='8M88D'></bdo><ul id='8M88D'></ul>
    <legend id='8M88D'><style id='8M88D'><dir id='8M88D'><q id='8M88D'></q></dir></style></legend>
    <i id='8M88D'><tr id='8M88D'><dt id='8M88D'><q id='8M88D'><span id='8M88D'><b id='8M88D'><form id='8M88D'><ins id='8M88D'></ins><ul id='8M88D'></ul><sub id='8M88D'></sub></form><legend id='8M88D'></legend><bdo id='8M88D'><pre id='8M88D'><center id='8M88D'></center></pre></bdo></b><th id='8M88D'></th></span></q></dt></tr></i><div id='8M88D'><tfoot id='8M88D'></tfoot><dl id='8M88D'><fieldset id='8M88D'></fieldset></dl></div>

    <small id='8M88D'></small><noframes id='8M88D'>

  1. <tfoot id='8M88D'></tfoot>

      ORA-04021: 等待锁定对象时发生超时

      ORA-04021: timeout occurred while waiting to lock object(ORA-04021: 等待锁定对象时发生超时)
      <i id='MloxN'><tr id='MloxN'><dt id='MloxN'><q id='MloxN'><span id='MloxN'><b id='MloxN'><form id='MloxN'><ins id='MloxN'></ins><ul id='MloxN'></ul><sub id='MloxN'></sub></form><legend id='MloxN'></legend><bdo id='MloxN'><pre id='MloxN'><center id='MloxN'></center></pre></bdo></b><th id='MloxN'></th></span></q></dt></tr></i><div id='MloxN'><tfoot id='MloxN'></tfoot><dl id='MloxN'><fieldset id='MloxN'></fieldset></dl></div>
      <tfoot id='MloxN'></tfoot>

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

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

                <legend id='MloxN'><style id='MloxN'><dir id='MloxN'><q id='MloxN'></q></dir></style></legend>
                  <tbody id='MloxN'></tbody>

                本文介绍了ORA-04021: 等待锁定对象时发生超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有这个匿名 PL/SQL 块,它计算并打印从表中返回的值.

                I have this anonymous PL/SQL block which calculates and prints a value return from a table.

                DECLARE
                    U_ID NUMBER :=39;
                    RETAIL BINARY_FLOAT:=1;
                    FLAG NUMBER;
                BEGIN
                    SELECT NVL(RETAIL_AMOUNT,1),UNIT_ID INTO RETAIL, FLAG FROM UNITS WHERE UNIT_ID=U_ID;
                    LOOP
                    SELECT NVL(MAX(UNIT_ID),U_ID) INTO FLAG FROM  UNITS WHERE FATHER_ID=FLAG;
                    IF FLAG=U_ID THEN EXIT; END IF;
                    SELECT RETAIL* RETAIL_AMOUNT INTO RETAIL FROM UNITS WHERE UNIT_ID=FLAG;
                    EXIT WHEN FLAG=U_ID;
                    END LOOP;
                DBMS_OUTPUT.PUT_LINE( RETAIL);
                END;
                

                这个块可以正常工作,但我想使用 PL/SQL 函数来做同样的事情

                This block work correctly, but I wanted to do the same thing using a PL/SQL Function

                我写的函数如下:

                CREATE OR REPLACE FUNCTION GET_UNIT_RETAIL(U_ID NUMBER)
                     RETURN NUMBER
                IS
                    RETAIL BINARY_FLOAT:=1;
                    FLAG NUMBER;
                BEGIN
                    SELECT NVL(RETAIL_AMOUNT,1),UNIT_ID 
                    INTO RETAIL, FLAG 
                    FROM UNITS 
                    WHERE UNIT_ID=U_ID;
                
                    LOOP
                        SELECT NVL(MAX(UNIT_ID),U_ID) 
                        INTO FLAG 
                        FROM  UNITS 
                        WHERE FATHER_ID=FLAG;
                        IF FLAG=U_ID THEN 
                            EXIT; 
                        END IF;
                        SELECT RETAIL* RETAIL_AMOUNT 
                        INTO RETAIL 
                        FROM UNITS 
                        WHERE UNIT_ID=FLAG;
                        EXIT WHEN FLAG=U_ID;
                    END LOOP;
                
                    RETURN NUMBER;
                END;
                /
                

                当我尝试执行上面的代码将函数保存到数据库时,环境(SQL*PLUS)挂了很长时间,最后返回这个错误:

                When I try to execute the above code to save the function to the database, the environment (SQL*PLUS) hangs for a long time and at the end returns this error:

                错误在第 1 行:
                ORA-04021: 等待锁定对象时发生超时

                ERROR at line 1:
                ORA-04021: timeout occurred while waiting to lock object

                有什么问题???请!

                推荐答案

                听起来像ddl_lock问题

                看看
                dba_ddl_locks 以查看谁在阻止"创建或替换.

                Take a look at
                dba_ddl_locks to see who is "blocking" a create or replace.

                还尝试在不同名称下创建 - 看看会发生什么.

                Also try to create under different name - and see what happens.

                这篇关于ORA-04021: 等待锁定对象时发生超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                How to redirect the output of DBMS_OUTPUT.PUT_LINE to a file?(如何将 DBMS_OUTPUT.PUT_LINE 的输出重定向到文件?)
                How do I get column datatype in Oracle with PL-SQL with low privileges?(如何使用低权限的 PL-SQL 在 Oracle 中获取列数据类型?)
                Get a list of all functions and procedures in an Oracle database(获取 Oracle 数据库中所有函数和过程的列表)
                Why cannot I create triggers on objects owned by SYS?(为什么我不能在 SYS 拥有的对象上创建触发器?)
                Returning result even for elements in IN list that don#39;t exist in table(即使对于表中不存在的 IN 列表中的元素也返回结果)
                Reset Sequence in oracle 11g(oracle 11g 中的重置序列)
              1. <tfoot id='Iv13B'></tfoot>
                <legend id='Iv13B'><style id='Iv13B'><dir id='Iv13B'><q id='Iv13B'></q></dir></style></legend>

                  • <i id='Iv13B'><tr id='Iv13B'><dt id='Iv13B'><q id='Iv13B'><span id='Iv13B'><b id='Iv13B'><form id='Iv13B'><ins id='Iv13B'></ins><ul id='Iv13B'></ul><sub id='Iv13B'></sub></form><legend id='Iv13B'></legend><bdo id='Iv13B'><pre id='Iv13B'><center id='Iv13B'></center></pre></bdo></b><th id='Iv13B'></th></span></q></dt></tr></i><div id='Iv13B'><tfoot id='Iv13B'></tfoot><dl id='Iv13B'><fieldset id='Iv13B'></fieldset></dl></div>
                  • <small id='Iv13B'></small><noframes id='Iv13B'>

                      <tbody id='Iv13B'></tbody>

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