我有一个查询通过 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