I am trying to retrieve records from oracle 10g express.
I want to execute :
select name|| '=' || id from literals where name='vge_1'
only when count(vge_1) is equal to 1.
else I want to display an error.
I tried following query, but its giving
ORA-00905: missing keyword
THe query I tried is as follows:
select case(name)
when count('vge_1') then (select name|| '=' || id from literals where name='vge_1';)
else Errror
end
from Literals where name='vge_1';
Thanks for your help in advance.
Try this SQL Fiddle:
The inner query is roughly same as the other answers. The outer query uses a left outer join
(+)to determine if the inner query contains a match for yourcount()restriction.Note that you must update the name in two places when running this query.