Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORA-01445: cannot select ROWID from, or sample, a join view without a key-p

442171May 2 2011 — edited May 3 2011
Hi All,

I am facing issue with one sql query. It is giving me error:
ORA-01445: cannot select ROWID from, or sample, a join view without a key-preserved table

I am not getting any clue to solve this. On internet, i didn't find proper reason for this error and troubleshooting way and solution for this error. Everywhere i saw one sentence, "Key preserved means the row from the base table will appear AT MOST ONCE in the output view on that table" but it didn't solve my problem.

I have 1099 columns in one select query. so avoiding the actual column list in select clause. Instead I am trying to select ROWIDs from all tables in join. My understanding is ROWID is a unique identifier in table not in database. But though I remove ROWIDs, I get same error. So please don't bother about these ROWIDs.

SELECT

TO_DATE(FACT.BUS_DATE_FKID,'YYYYMMDD')
,FACT.ROWID AS ABC1
,FACT_ADJ.ROWID AS ABC2
,DIM_SEC.ROWID AS ABC3
,DIM_SEC_ADJ.ROWID AS ABC4
,DIS_CAT.ROWID AS ABC5
,CTRY.ROWID AS ABC6
,BCP.ROWID AS ABC7
,STAGE.ROWID AS ABC8

FROM FACT_POSITION FACT
LEFT JOIN FACT_POSITION_ADJ FACT_ADJ ON FACT.POSITION_PKID = FACT_ADJ.POSITION_FKID
LEFT JOIN DIM_SOURCE_SYSTEM SOURCE ON FACT.SOURCE_SYSTEM_FKID = SOURCE.SOURCE_SYSTEM_PKID
LEFT JOIN DIM_SECURITY DIM_SEC ON FACT.SUBSYS_SECURITY_FKID = DIM_SEC.SECURITY_PKID
LEFT JOIN DIM_SECURITY_ADJ DIM_SEC_ADJ ON FACT.SUBSYS_SECURITY_FKID = DIM_SEC_ADJ.SECURITY_PKID
LEFT JOIN DIM_DISCLOSURE_CATEGORY DIS_CAT ON FACT.DISCLOSURE_CATEGORY_FKID = DIS_CAT.DISCLOSURE_CATEGORY_PKID
LEFT JOIN COUNTRY_REFERENCE CTRY ON CTRY.DESCRIPTION = DIM_SEC.ISSUER_COUNTRY
LEFT JOIN BUSINESS_CLOSE_PERIOD BCP
ON BCP.BUSINESS_CLOSE_DATE = ADD_MONTHS(TRUNC(TO_DATE(FACT.BUS_DATE_FKID,'YYYYMMDD'),'MM'), 1) -1
AND BCP.IS_LOCKED='Y' AND BCP.IS_ACTIVE='Y'
LEFT JOIN GUI_STAGING STAGE ON
(
FACT.POSITION_PKID=STAGE.POSITION_PKID
AND STAGE.IS_ACTIVE='Y'
AND STAGE.STATUS_ID IN(12,8,1,2,3,4,5)
)
WHERE FACT.POSITION_PKID=64524374;

While trying to sort this error, I found interesting things that made me more confused.

if I remove TO_DATE function from select clause, same join query works.
If I remove any table from join and keep TO_DATE function in select clause, query works.
That tells, there is no problem in query.

Then please anyone help me to sort out the error. FYI. I have googled a lot for this error. but didn't get solution/clue. That is why I am posting this problem to forum.

Thanks in advance. waiting for reply ASAP.

Pravin Pujari
pravin.pujari@gmail.com
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 31 2011
Added on May 2 2011
6 comments
12,754 views