<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: 等待锁定对象时发生超时

      时间:2023-11-02
      <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: 等待锁定对象时发生超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:将日期与预定义格式 pl sql 进行比较 下一篇:在一个过程中调用另一个 PL/SQL 过程

                相关文章

              1. <tfoot id='Iv13B'></tfoot>
                <legend id='Iv13B'><style id='Iv13B'><dir id='Iv13B'><q id='Iv13B'></q></dir></style></legend>

                1. <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>
                2. <small id='Iv13B'></small><noframes id='Iv13B'>

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