-2

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

SQL> select count(*) from HZ_CUST_SITE_USES;

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

SQL>

你能帮我一个吗

4

1 回答 1

1

根据 My Oracle Support(文档 ID 787677.1),您在 APPS 拥有的同义词上启用了安全策略

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

首先,确认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关联的视图, :ARHZ_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      
于 2017-07-13T15:20:00.933 回答