0

我有一个查询通过 db 链接从两个表中获取数据,如下所示:

SELECT a.ID, a.NAME, b.address
  FROM table1@dblink a, table2@dblink b
 WHERE a.ID = b.ID;

这工作得很好。然后我为此创建一个视图,如下所示:

CREATE VIEW myview
AS
   SELECT a.ID, a.NAME, b.address
     FROM table1@dblink a, table2@dblink b
    WHERE a.ID = b.ID;

视图创建成功。但是当我从如下视图中选择数据时:

SELECT *
  FROM myview

我收到如下错误:

ORA-00942: table or view does not exist
ORA-02063: preceding line from MYLINK

可能是什么问题?

编辑:

尝试了不同的方法,最终得到了不同的错误。在这里,我发布了确切的查询和最新的错误:

CREATE OR REPLACE VIEW plan_view
AS
   WITH plan_name AS
        (SELECT     fcr.argument1 AS plan_name, fcr.request_id AS request_id
               FROM apps.fnd_concurrent_requests@dblink fcr
              WHERE argument1 IN
                             ('E10', 'E20', 'E40', 'E60L', 'EDC', 'PS1', 'S')
         CONNECT BY PRIOR fcr.request_id = fcr.parent_request_id
         START WITH request_id =                                 -- '58043920'
                       (SELECT MAX (request_id) AS request_id
                          FROM apps.fnd_concurrent_requests@dblink
                         WHERE description = 'Mail Program'
                           AND actual_start_date >=
                                  TO_DATE (   TO_CHAR (TRUNC (SYSDATE - 1),
                                                       'mm-dd-yyyy'
                                                      )
                                           || '05:00:00 PM',
                                           'MM-DD-YYYY HH:MI:SS PM'
                                          )
                           AND actual_start_date < SYSDATE)),
        e10 AS
        (SELECT     TRIM
                       (BOTH ' ' FROM (SELECT meaning
                                         FROM apps.fnd_lookup_values@dblink
                                        WHERE lookup_type = 'CP_STATUS_CODE'
                                          AND lookup_code = fcr.status_code
                                          AND view_application_id = 0)
                       ) status,
                    TRIM
                       (BOTH ' ' FROM (SELECT meaning
                                         FROM apps.fnd_lookup_values@dblink
                                        WHERE lookup_type = 'CP_PHASE_CODE'
                                          AND lookup_code = fcr.phase_code
                                          AND view_application_id = 0)
                       ) phase,
                    fcr.request_id AS rid,
                    fcr.actual_start_date AS start_date,
                    fcr.actual_completion_date AS completion_date
               FROM apps.fnd_concurrent_requests@dblink fcr
         CONNECT BY PRIOR fcr.request_id = fcr.parent_request_id
         START WITH request_id = (SELECT request_id
                                    FROM plan_name
                                   WHERE plan_name IN ('E10')))
   SELECT 'E10' "PLAN_NAME", (SELECT MIN (start_date)
                                FROM e10) "START_DATE",
          (SELECT COUNT (rid)
             FROM e10)
     FROM DUAL

当我尝试直接从查询中选择时,我得到了正确的输出。但是在我创建视图并尝试后,select * from plan_view我收到以下错误:

ORA-00604: error occurred at recursive SQL level 1
ORA-00904: "FCR"."REQUEST_ID": invalid identifier
4

1 回答 1

1

这听起来像是授予权限的老问题。对于 ad hoc DML(选择、插入等),我们可以使用通过角色授予的权限。但是要构建永久对象——视图、存储过程等——我们必须直接授予用户权限。

因此,对您描述的现象的最常见解释是表的所有者已将这些表的权限授予一个角色而不是您。

于 2013-07-23T08:28:38.593 回答