Jagadish Patnala
Jagadish Patnala

Reputation: 1

ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended

Select S.sname
From    suppliers s
where not exists (
(select * from parts p where p.color = 'red')  ; all red parts
except
(select c.pid from catalog c, parts p where c.sid = s.sid
and c.pid = p.pid and p.color = 'red'))


select  p.pname
from    parts p. catalog c, suppliers s
where   p.pid = c.pid and c.sid = s.sid
AND s.sname = 'S1'

AND not exists (  # another supplier
select * from catalog c1, suppliers s1
where p.pid = c1.pid and c1.sid = s1.sid
AND s1.sname <> 'S1')

When I am executing the above two queries it is showing SQL command not properly ended

Upvotes: 0

Views: 141

Answers (1)

Littlefoot
Littlefoot

Reputation: 142713

Probably because they are invalid; what are those

  • ; all red parts except and
  • # another supplier

supposed to do? Comments, perhaps? In Oracle, you'd use -- or enclose comments into /* ... */.

This is, probably, somewhat better:

First query:

Select S.sname 
From suppliers s 
where not exists ( (select * 
                    from parts p 
                    where p.color = 'red'
                   ) 
                    minus 
                   (select c.pid 
                    from catalog c, parts p 
                    where c.sid = s.sid 
                      and c.pid = p.pid 
                      and p.color = 'red'
                   )
                 );

Second query:

select p.pname 
from parts p, catalog c, suppliers s 
where p.pid = c.pid 
  and c.sid = s.sid 
  AND s.sname = 'S1'
  AND not exists (select * 
                   from catalog c1, suppliers s1 
                   where p.pid = c1.pid 
                     and c1.sid = s1.sid 
                     AND s1.sname <> 'S1'
                 );                 

Upvotes: 1

Related Questions