I have a view with a query of the following form which works perfectly when I query it on the local server from any schema:
WITH dates AS (
SELECT /*+ materialize */ ... FROM ( SELECT ... FROM table@link)
UNION ALL
SELECT * FROM ( SELECT /*+ materialize */ FROM table@link )
)
SELECT ... FROM (
SELECT ... FROM (
SELECT ... FROM (
SELECT ... FROM (
SELECT ... FROM
)
) foo
LEFT OUTER JOIN (
SELECT /*+ USE_MERGE(hle dates) */ ... FROM
) bar ON conditions
)
)
UNION ALL
SELECT ... FROM (
SELECT ... FROM (
SELECT ... FROM (
SELECT ... FROM (
SELECT ... FROM
)
) foo
LEFT OUTER JOIN (
SELECT /*+ USE_MERGE(hle dates) */ ... FROM
) bar ON conditions
)
)
When I run the query from any remote db link on any other server, e.g. SELECT * from someschema.my_view@db_link
, I get:
ORA-00928: missing SELECT keyword
ORA-02063: preceding line from PLLDB
00928. 00000 - "missing SELECT keyword"
*Cause:
*Action:
Error at Line: 2 Column: 9
Oracle thinks line 2 is a problem. Here are the first five actual lines:
WITH dates AS (
-- Get days
SELECT /*+ materialize */
row_number() OVER (ORDER BY begin_period DESC) rn,
'D' AS interval_type,
All other views work perfectly over the DB link (once edited to work around any related Oracle bugs).
Why does this view work perfectly locally but not over a db link?