【问题标题】:get_release Oracle API returning "Unknown" result instead of correct releaseget_release Oracle API 返回“未知”结果而不是正确版本
【发布时间】:2016-10-14 23:32:58
【问题描述】:

从应用程序用户执行以下 get_release 函数时,它返回正确的版本:12.1.3,但是当从另一个用户执行它时,它返回 Unknown 结果:

declare
l_release_name         varchar2(30);
l_other_release_info   varchar2(2000);
   begin
     if not apps.FND_RELEASE.get_release (l_release_name, l_other_release_info) then
         null;
     end if;
     dbms_output.put_line(l_release_name);
   end;

FND_RELEASE.get_release 是一个公共包,应该没有限制从其他用户调用它。

低于我在函数 cmets 中找到的内容:

-- get_release() will usually return TRUE
  --  with RELEASE_NAME =
  --                    contents of RELEASE_NAME column in FND_PRODUCT_GROUPS
  --  and OTHER_RELEASE_INFO = null
  --
  -- If FND_PRODUCT_GROUPS.RELEASE_NAME contains imbedded spaces:
  --
  -- get_release() will return TRUE
  --  with RELEASE_NAME = FND_PRODUCT_GROUPS.RELEASE_NAME up to but
  --   not including the first imbedded space
  --  and OTHER_RELEASE_INFO = FND_PRODUCT_GROUPS.RELEASE_NAME
  --   starting with the first non-space character after the first
  --   imbedded space
  --
  -- On failure, get_release() returns FALSE. This will be a performance issue.
  --  Both RELEASE_NAME and OTHER_RELEASE_INFO will be set to 'Unknown'.
  --  This indicates that either:
  --  1) there are no rows in fnd_product_groups
  --     - this can be resolved by populating the row and it will
  --       be queried on the next call.
  --  2) there is more than one row in fnd_product_groups
  --     - delete all but the one correct row from fnd_product_groups and it
  --       will be queried on the next call. It's possible that the values
  --       returned by release_* and *_version routines are still correct if
  --       the first row in fnd_product_groups, ordered by product_group_id,
  --       if the currect row, but this will still be a performance problem.

以前有人遇到过这个问题吗?!

【问题讨论】:

    标签: oracle erp oracle-ebs


    【解决方案1】:

    据我所知有3种可能性:

    1. FND_RELEASE 使用invoker_rights_clause (AUTHID CURRENT_USER) 编译。它为用户apps 和任何其他用户使用不同的来源。
    2. 函数 FND_RELEASE.get_release 使用 context 进行访问。
    3. 在您的系统中使用了private database 选项。它能够重写查询并向当前用户添加条件。(第 2 点的变化,但隐含)

    【讨论】:

      【解决方案2】:

      我看到您正在使用 Oracle e-Business Suite 数据模型和数据包。

      在该软件包中,FND_RELEASE 被声明为AUTHID CURRENT_USER(即,它使用调用者的权限)。您可以在包规范的第一行看到这一点。

      这意味着该查询中正在查看FND_PRODUCT_GROUPS 表...

      select   release_name
      from     fnd_product_groups
      order by product_group_id;
      

      ... NOT APPS.FND_PRODUCT_GROUPS.. 它是当前用户拥有的FND_PRODUCT_GROUPS 表。

      由于该用户可能没有FND_PRODUCT_GROUPS 表,因此FND_RELEASE 在尝试运行该查询时会引发ORA-00942: table or view does not exist 错误。

      这会导致它跳到其WHEN OTHERS 异常处理程序,这会导致它返回 false 并将输出参数设置为“未知”。

      解决此问题的一种方法是为FND_RELEASE 创建一个使用定义者权限的自定义包装器。像这样:

      create or replace package xxcust_fnd_release AUTHID DEFINER IS
      
        function get_release (release_name       out nocopy varchar2,
                              other_release_info out nocopy varchar2)
        return boolean;
      end xxcust_fnd_release;
      
      
      create or replace package body xxcust_fnd_release IS
      
        function get_release (release_name       out nocopy varchar2,
                              other_release_info out nocopy varchar2)
        return boolean IS
        BEGIN
          return fnd_release.get_release (release_name, other_release_info);
        END;
      end xxcust_fnd_release;
      
      grant execute on xxcust_fnd_release to <your_other_username>;
      

      如果您这样做,并按如下方式修改您的脚本,它将起作用:

      declare
      l_release_name         varchar2(30);
      l_other_release_info   varchar2(2000);
         begin
           if not apps.XXCUST_FND_RELEASE.get_release (l_release_name, l_other_release_info) then
               null;
           end if;
           dbms_output.put_line(l_release_name);
         end;
      

      替代解决方法

      如果您不能或不想在 APPS 架构中创建新的包装程序包,您可以在其他用户的架构中创建 FND_PRODUCT_GROUPS 的同义词。

      例如,

      create or replace synonym fnd_product_groups FOR apps.fnd_product_groups;
      

      ...在您的其他架构中执行此操作,您的原始脚本将起作用。

      此替代方案的缺点是 Oracle 补丁可能会更改 FND_RELEASE 的逻辑以在其他表上引入其他查询,从而导致此解决方案中断,直到您创建所需的任何其他同义词。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-01-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多