HZ_CUST_SITE_USES没有返回任何行

时间:2017-07-13 12:40:40

标签: oracle role-based-access-control

查询下表时,它返回零记录。

SQL> select count(*) from HZ_CUST_SITE_USES;

COUNT(*)
----------
        0

SQL>
你能帮我一个人吗

1 个答案:

答案 0 :(得分:1)

根据我的Oracle支持(文档ID 787677.1),您已在APPS拥有的同义词上启用安全策略

这是与Oracle R12环境中APPS@ERP拥有的同义词相关联的标准设置。

首先,确认在未设置组织特定安全策略上下文的情况下查询时APPS@ERP拥有的同义词将导致空集:

APPS@ERP>SELECT COUNT(1) FROM HZ_CUST_SITE_USES;
COUNT(1)  
0         

接下来确认已对此APPS@ERP拥有的同义词应用了安全策略:

APPS@erp>SELECT object_name,
  2    policy_group,
  3    policy_name,
  4    PACKAGE,
  5    FUNCTION,
  6    sel,
  7    enable
  8  FROM dba_policies
  9  WHERE object_name = 'HZ_CUST_SITE_USES';
OBJECT_NAME        POLICY_GROUP  POLICY_NAME  PACKAGE    FUNCTION      SEL  ENABLE  
HZ_CUST_SITE_USES  SYS_DEFAULT   ORG_SEC      MO_GLOBAL  ORG_SECURITY  YES  YES     

只需确认对象类型是同义词:

APPS@erp>SELECT owner,
  2    object_name,
  3    object_type
  4  FROM DBA_OBJECTS
  5  WHERE 1         =1
  6  AND OBJECT_NAME = 'HZ_CUST_SITE_USES';
OWNER  OBJECT_NAME        OBJECT_TYPE  
APPS   HZ_CUST_SITE_USES  SYNONYM      

查询与APPS@ERP拥有的表AR相关联的HZ_CUST_SITE_USES_ALL视图:

APPS@erp>--APPS owned view r12.2
APPS@erp>SELECT ORG_ID, COUNT(1) FROM HZ_CUST_SITE_USES_ALL GROUP BY ORG_ID;
ORG_ID  COUNT(1)  
123     458       
456     2658      
789     1210      

为会话设置上下文(org_id为456)后,可以查询该org_id的结果:

APPS@erp>--set policy
APPS@erp>EXEC mo_global.set_policy_context('S', 456);

PL/SQL procedure successfully completed.

APPS@erp>SELECT COUNT(1) FROM HZ_CUST_SITE_USES;
COUNT(1)  
2658