• <tfoot id='Rdjh3'></tfoot>

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

      1. <legend id='Rdjh3'><style id='Rdjh3'><dir id='Rdjh3'><q id='Rdjh3'></q></dir></style></legend>
          <bdo id='Rdjh3'></bdo><ul id='Rdjh3'></ul>

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

        为什么我得到 PLS-00302:组件存在时必须声明?

        Why do I get PLS-00302: component must be declared when it exists?(为什么我得到 PLS-00302:组件存在时必须声明?)

          <legend id='eWvye'><style id='eWvye'><dir id='eWvye'><q id='eWvye'></q></dir></style></legend>

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

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

                • <bdo id='eWvye'></bdo><ul id='eWvye'></ul>
                • 本文介绍了为什么我得到 PLS-00302:组件存在时必须声明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用的是 Oracle 10.2.

                  I am using Oracle 10.2.

                  我正在编写一些脚本,将一些 ORACLE 对象从一个 SCHEMA (S1) 移动到另一个 (S2).我正在创建具有 DBA 角色的函数.移动时,我的一个功能无效,但我不明白为什么.它的代码是这样的:

                  I am working in some scripts to move some ORACLE Objects from one SCHEMA (S1) to another (S2). I am creating the functions with DBA role. When moved, one of my functions becomes invalid, but I don't understand why. Its code goes along these lines:

                  MY_FUNC

                  CREATE OR REPLACE FUNCTION S2."MY_FUNC" RETURN VARCHAR2 IS
                     something VARCHAR2;
                     othervar VARCHAR2 (50):= 'TEST';   
                  BEGIN
                     something := S2.MY_FUNC2();
                      /*some code*/
                      return othervar;
                  END;
                  /
                  

                  如果我在没有架构的情况下使用 MY_FUNC2,它可以工作:
                  something := MY_FUNC2(); 而不是 something := S2.MY_FUNC2();

                  If I use MY_FUNC2 without the schema, It works:
                  something := MY_FUNC2(); instead of something := S2.MY_FUNC2();

                  My_FUNC2

                  CREATE OR REPLACE FUNCTION S2."MY_FUNC2" RETURN VARCHAR2 IS
                         something BOOLEAN;
                         othervar VARCHAR2 (50) := 'TEST2';           
                      BEGIN
                         /*some code*/
                          return othervar;
                      END;
                      /
                  

                  MY_FUNC2 有这样的同义词:

                  MY_FUNC2 has a synonym like this:

                   CREATE OR REPLACE PUBLIC SYNONYM "MY_FUNC2" FOR "S2"."MY_FUNC2"
                  

                  MY_FUNC 编译出错:

                  PLS-00302:必须声明组件MY_FUNC2"

                  PLS-00302: component 'MY_FUNC2' must be declared

                  我不明白为什么我会收到这个错误,当我的函数在另一个模式 (S1) 中时,它们具有完全相同的结构,并且同义词的创建完全相同(但指向 S1)和 MY_FUNC 编译良好.

                  I don't understand why I am getting this error, when my functions were in the other schema (S1) they had exactly the same structure and the synonym was created exactly the same (but pointing to S1) and MY_FUNC compiled fine.

                  我最初没有创建这个函数和同义词.是不是我在 S2 中缺少一些权限,所以 MY_FUNC 可以正常工作?

                  I didn't create this functions and synonym originally. Is it possible that I am missing some privileges in S2, so MY_FUNC can work properly?

                  推荐答案

                  如果您有一个与架构同名的对象,就会出现该错误.例如:

                  You can get that error if you have an object with the same name as the schema. For example:

                  create sequence s2;
                  
                  begin
                    s2.a;
                  end;
                  /
                  
                  ORA-06550: line 2, column 6:
                  PLS-00302: component 'A' must be declared
                  ORA-06550: line 2, column 3:
                  PL/SQL: Statement ignored
                  

                  当您引用 S2.MY_FUNC2 时,对象名称正在解析,因此它不会尝试将 S2 评估为架构名称.当您将其称为 MY_FUNC2 时,没有任何混淆,因此它可以工作.

                  When you refer to S2.MY_FUNC2 the object name is being resolved so it doesn't try to evaluate S2 as a schema name. When you just call it as MY_FUNC2 there is no confusion, so it works.

                  文档解释了名称解析.限定对象名称的第一部分 - 此处为 S2 - 在被评估为不同模式之前被评估为当前模式上的对象.

                  The documentation explains name resolution. The first piece of the qualified object name - S2 here - is evaluated as an object on the current schema before it is evaluated as a different schema.

                  它可能不是一个序列;其他对象可能会导致相同的错误.您可以通过查询数据字典来检查是否存在同名对象.

                  It might not be a sequence; other objects can cause the same error. You can check for the existence of objects with the same name by querying the data dictionary.

                  select owner, object_type, object_name
                  from all_objects
                  where object_name = 'S2';
                  

                  这篇关于为什么我得到 PLS-00302:组件存在时必须声明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 中的重置序列)
                  <i id='Y07xB'><tr id='Y07xB'><dt id='Y07xB'><q id='Y07xB'><span id='Y07xB'><b id='Y07xB'><form id='Y07xB'><ins id='Y07xB'></ins><ul id='Y07xB'></ul><sub id='Y07xB'></sub></form><legend id='Y07xB'></legend><bdo id='Y07xB'><pre id='Y07xB'><center id='Y07xB'></center></pre></bdo></b><th id='Y07xB'></th></span></q></dt></tr></i><div id='Y07xB'><tfoot id='Y07xB'></tfoot><dl id='Y07xB'><fieldset id='Y07xB'></fieldset></dl></div>

                  <legend id='Y07xB'><style id='Y07xB'><dir id='Y07xB'><q id='Y07xB'></q></dir></style></legend>
                    1. <tfoot id='Y07xB'></tfoot>
                      • <small id='Y07xB'></small><noframes id='Y07xB'>

                          <bdo id='Y07xB'></bdo><ul id='Y07xB'></ul>
                            <tbody id='Y07xB'></tbody>