[英]Unable to fetch data from a view that accesses data over db link
I have a query to fetch data from two tables over a db link as below: 我有一个查询,通过数据库链接从两个表中获取数据,如下所示:
SELECT a.ID, a.NAME, b.address
FROM table1@dblink a, table2@dblink b
WHERE a.ID = b.ID;
This works perfectly fine. 这工作得很好。 Then I create a view for this as below:
然后,我为此创建一个视图,如下所示:
CREATE VIEW myview
AS
SELECT a.ID, a.NAME, b.address
FROM table1@dblink a, table2@dblink b
WHERE a.ID = b.ID;
View is created successfully. 视图创建成功。 But when I select data from the view as below:
但是,当我从视图中选择数据时,如下所示:
SELECT *
FROM myview
I get error like: 我收到如下错误:
ORA-00942: table or view does not exist
ORA-02063: preceding line from MYLINK
What could probably be the issue? 可能是什么问题?
EDIT: 编辑:
Tried different methods and ended up getting different error. 尝试了不同的方法,最终得到了不同的错误。 Here I am posting the exact query and the latest error:
在这里,我发布确切的查询和最新的错误:
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
When I try selecting directly from the query I get proper output. 当我尝试直接从查询中选择时,我得到正确的输出。 But after I create the view and try
select * from plan_view
I get the below error: 但是在创建视图并尝试
select * from plan_view
以下错误:
ORA-00604: error occurred at recursive SQL level 1
ORA-00904: "FCR"."REQUEST_ID": invalid identifier
This sounds like the old problem with granting privileges. 这听起来像授予权限的旧问题。 For ad hoc DML (select, insert, etc) we can use privileges granted through a role.
对于临时DML(选择,插入等),我们可以使用通过角色授予的特权。 But to build permanent objects - views, stored procedures, etc - we must have privileges granted to the user directly.
但是要构建永久对象-视图,存储过程等-我们必须直接将特权授予用户。
So, the most common explanation for the phenomenon you describe is that the tables' owner has granted rights on those tables to a role not to you. 因此,对您描述的现象的最常见解释是表的所有者已将对这些表的权限授予了您不属于的角色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.