Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

View Compiles but Selecting It Returns Error

Status
Not open for further replies.

thermidor

Programmer
Joined
Nov 28, 2001
Messages
123
Location
US
Hi All,

I have created a view with the definition below - please be patient, it's not as hairy as it looks at first). The problem here is I can create the view, but when I try to select on the view I get a "ORA-00907: missing right parenthesis" error. I also get this error if I try to run the SQL separately. I'm confused because the statement is not that complicated. If I run the part in red, it runs fine...

This one really has me pulling my hair out. If anyone can give any insight/suggestions, I'd really appreciate it.

TIA,
Sven

SELECT
acct.acctcd AS acctcd,
upper(acct.acctdsc) AS acctshortnm,
coalesce(chsup.chcd,' ') AS chcd,
upper(coalesce(chsup.chshortnm,' ')) AS chshortnm,
coalesce(chsup.schcd,' ') AS schcd,
upper(coalesce(chsup.schshortnm,' ')) AS schshortnm,
SYSDATE AS effdt
FROM
acct acct
LEFT JOIN
(SELECT
acctcd,
acctshortnm,
src,
chcd,
chshortnm,
schcd,
schshortnm
FROM
((SELECT
ch.chcd AS chcd,
ch.chshortnm AS chshortnm,
s.schcd AS schcd,
s.schshortnm AS schshortnm,
s.schcd AS acctcd,
s.schshortnm AS acctshortnm,
'S' AS src
FROM Cch ch
LEFT JOIN
chs s
ON ch.schcd=s.schcd )
UNION ALL (
SELECT ch.chcd AS chcd,
ch.chshortnm AS chshortnm,
s.schcd AS schcd,
s.schshortnm AS schshortnm,
ch.chcd AS acctcd,
ch.chshortnm AS acctshortnm,
'C' AS src
FROM ch ch
LEFT JOIN
chs s
ON ch.schcd=s.schcd) ) x
WHERE acctcd IS NOT NULL) [/color red]
chsup ON acct.acctcd = chsup.acctcd
 
You are missing a join or something:
Code:
SELECT acct.acctcd AS acctcd, ...
  FROM acct acct 
  LEFT JOIN 
   +->(SELECT acctcd, acctshortnm, ...
   |     FROM 
   |   +->((SELECT ch.chcd AS chcd, ...
   |   |     FROM Cch ch 
   |   |     LEFT JOIN chs s ON ch.schcd=s.schcd) 
   |   |   UNION ALL 
   |   |  (SELECT ch.chcd AS chcd, ...
   |   |     FROM ch ch 
   |   |     LEFT JOIN chs s ON ch.schcd=s.schcd)
   |   +->) x 
   +--> WHERE acctcd IS NOT NULL) 
 ???->chsup ON acct.acctcd = chsup.acctcd
[ponder]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Unless, chsup is the ALIAS? -- then all parentesis do seem to match!


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
chsup is the alias.
What makes this even more confusing to me is I took the part that "works" (in red int the first post) and put it into a separate view. So then I could simplify my view definition to something like:
SELECT acct.acctcd AS acctcd, ...
FROM acct acct
LEFT JOIN
(SELECT * from tmpview)
chsup ON acct.acctcd = chsup.acctcd

Unfortunately this returned the same error...

Thanks,
Sven
 
Does this second view execute correctly by itself?


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
The second view worked correctly. That is it compiled and I was able to select from it...
 
Just a hunch, but change second view to:
Code:
SELECT acct.acctcd AS acctcd, ...
  FROM acct acct 
  LEFT JOIN tmpview chsup
    ON acct.acctcd = chsup.acctcd

I have no way to reproduce the issue because I have version 8.1.7 (no LEFT JOIN syntax). [sadeyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Based on my research this is a known Oracle bug affecting versions < 10.2.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top