Problem with a bracket [message #262742] |
Tue, 28 August 2007 03:51 |
embopazb
Messages: 10 Registered: August 2007
|
Junior Member |
|
|
When I execute this statement I get ORA-00907. I cant see where I did not include the bracket. Could anyone help?
SELECT
ID, zaklad_id, lokalizacja_id, jednostka_id, rachunek_id,
rodzaj, numer, nr, nazwa, opis, data_przyjecia, data_likwidacji,
status
FROM st.st_srodek s, (SELECT ROWNUM + 2004 rok
FROM st.ST_SLOWNIK_KST
WHERE ROWNUM <100 ) r
WHERE (s.srodek_id IN (SELECT srodek_id FROM ST.ST_SRODEK_V
WHERE 1=1 AND JEDNOSTKA_ID = 18651 AND STATUS IN ('A','W')ORDER BY nr DESC, numer DESC)) OR
( s.zaklad_id = '1'
AND s.jednostka_id = '18651'
AND s.rodzaj LIKE 'R'
AND s.klasyfikacja IN
(SELECT slownik_id FROM st.st_slownik
WHERE typ = 'KLASYFIKACJA' AND wartosc0 LIKE '50%'
AND status = 'A' ))
AND r.rok >= TO_NUMBER(NVL(SUBSTR('01-STY-07',1,4),r.rok))
AND r.rok <= TO_NUMBER(NVL(SUBSTR('31-GRU-07',1,4),r.rok))
AND status IN ('A','W')
|
|
|
|
|
Re: Problem with a bracket [message #262748 is a reply to message #262742] |
Tue, 28 August 2007 04:00 |
embopazb
Messages: 10 Registered: August 2007
|
Junior Member |
|
|
The problem is with IN in this line
WHERE (s.srodek_id IN (SELECT srodek_id FROM ST.ST_SRODEK_V
still it seems that query is ok but the error occurs? I don't know what is the cause of this.
|
|
|
|
|
Re: Problem with a bracket [message #262754 is a reply to message #262750] |
Tue, 28 August 2007 04:17 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Is this your EXACT query? or have you 'simplified' it?
what is the point of this?
TO_NUMBER(NVL(SUBSTR('01-STY-07',1,4),r.rok))
(and others like it) other than to cause an Ora-01722 error?
What is the point of taking a substring of a literal? What is the point of performing an NVL on a string literal that is not null. How's about you tell us what you have actually done. If the query is what you have actually done, then you have more problems than unbalanced parentheses.
Edited to add code tags
[Updated on: Tue, 28 August 2007 04:18] Report message to a moderator
|
|
|
|
|
Re: Problem with a bracket [message #262798 is a reply to message #262758] |
Tue, 28 August 2007 05:22 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Quote: | Thank you for removing ORDER BY advice, I'm grateful!
|
That was possible because I understood your query (Slavs languages are quite similar, aren't they?); those guys from France, Scotland, Bangladesh, ... - they have no idea what you are selecting. So you see why it is important to study foreign languages, as well as read Forum Guides where available.
|
|
|