2
votes

After the migration of my oracle db im getting below error:

ORA-00904: "from$_subquery$_014"."TRN_TERMINAL_SOFTWARE_VERSION": invalid identifier

below is my query:

SELECT
  *
FROM
  (
    SELECT
      SUM(trn_amt)   AS amount,
      SUM(trn_count) AS COUNT ,
      timetype       AS period ,
      seq ,
      ROW_NUMBER() OVER (ORDER BY vw.seq DESC) AS RowNumber
    FROM
      YSD_STORE_FORWARD_V vw
    INNER JOIN store_dimension std                 ON vw.stm_id=std.std_id
    INNER JOIN card_type_dimension ctd             ON vw.CTD_CARD_ABBV=ctd.CTD_CARD_ABBV
    INNER JOIN STPLDBTEMP.store_group_relation sgr ON std.STD_ID= sgr.sgr_store_id
    INNER JOIN location_dimension ld               ON ld.lod_id=std.std_location_id
WHERE
  start_date BETWEEN 20170405 AND 20170405
AND std.std_corp_id    ='1939'
AND sgr.sgr_sgm_id     ='2160'
AND ctd.CTD_CARD_ABBV IN ('VE','VI','VS','VD','AX','AE','MD','MC','MF','XX'
  ,'DB','JB','NV','DS','EB','EBC','EBF','EBW','VF','VG','WX','DC','GF','PL'
  ,'PW','NM','BG','GC','FL','FO','FT','FW','INV','IV','IN','CP')
AND LD.LOD_COUNTRY_ID = 1
GROUP BY
  timetype ,
  seq
ORDER BY
  4

);

I'm not using column in my query still I'm getting this error, Please help me out YSD_STORE_FORWARD_V its a View which is using materialized view contain TRN_TERMINAL_SOFTWARE_VERSION column but my working is fine.

1
What happens if you run SELECT * FROM YSD_STORE_FORWARD_V? Do the columns match up with the columns you are using in the above query?MT0
A couple of questions -> 1. Does this object exists: TRN_TERMINAL_SOFTWARE_VERSION ? (try desc TRN_TERMINAL_SOFTWARE_VERSION ) 2. Does your user (running the query above) has READ privilege on it? 3. Does it reside on the same schema and on the same database?g00dy
Does removing the redundant subquery make any difference? Or at least moving the order by outside? The execution plan might help identify where that Oracle-generated subquery name fits in to the overall query. Sounds like it might be a parser bug though.... Which version is this, and which version did you migrate from, and how?Alex Poole
SELECT * FROM YSD_STORE_FORWARD_V is i run this query it gives me a result.zohaib daruwala
1. Does this object exists: TRN_TERMINAL_SOFTWARE_VERSION ? (try desc TRN_TERMINAL_SOFTWARE_VERSION ) ans: yes, In My VIEWS and MATERIALIZED VIEWS 2. Does your user (running the query above) has READ privilege on it? ANS: YES. 3. Does it reside on the same schema and on the same database? ANS: YESzohaib daruwala

1 Answers

3
votes

This is a bug in Oracle 11.2.0.4, it appears randomly in queries using subqueries or ansi join.

In my case I found the root cause: It was caused when I did a expdp from 11.2.0.4 and the schema has MATERIALIZED VIEWS. Then I did an impdp in other DataBase (10g, 11g and even 12c). Some kind of diccionary problem causes the bug.

I solved doing this:

  1. EXPDP excluding MATERIALIZED_VIEWS

  2. IMPDP. There were some errors related to MATERIALIZED_VIEW objects, wich were ignored.

  3. Create manually all the MATERIALIZED_VIEW objects.

  4. Recompile all objects in database, using “$ORACLE_HOME/rdbms/admin/utlrp.sql”

This is an extract of the bug documentation:

Bug 17551261 ORA-904 "from$_subquery$_003". with query rewrite

This note gives a brief overview of bug 17551261. The content was last updated on: 21-FEB-2014

Affects:

Product (Component) Oracle Server (Rdbms)

Range of versions believed to be affected Versions BELOW 12.1

Versions confirmed as being affected 11.2.0.4

Platforms affected Generic (all / most platforms affected)

It is believed to be a regression in default behaviour thus:
Regression introduced in 11.2.0.4

Fixed: The fix for 17551261 is first included in • 12.1.0.1 (Base Release)

Description This problem is introduced in 11.2.0.4 by the fix for bug 14049796 .

If an ORA-904 similar to the following is raised:
ORA-00904: "from$_subquery$_003"."SUBSCRIBER_SID": invalid identifier from a SQL statement using ANSI joins, then it may be a case of this bug if all of the following are true:

1) Summary rewrite is used

2) fix to bug:14049796 present (this fix is included in 11.2.0.4)

3) The errorstack includes kkogvcd() and kkqsgen()

Workaround Disable query rewrite