oracle - SQL CASE expression returning multiple rows -


i working cursor has case expression in 1 of where-clauses, so:

select tbl.id   table1 tbl  tbl.id = case                   when [some condition]                     [a single id number]                     else ( select tbl2.id                            table2 tbl2                            [some other condition]                          )                 end 

this works until sub-select returns multiple rows. if happens ora-01427 exception thrown. i've tried remedy using in or statements, looks me case expression unable output sets of multiple values.

if possible, how 1 create clause one, wherein sub-select potentially return multiple rows?

how can compare tbl.id = [multiple rows]?

you need use "exists" or " in " syntax. example:

select tbl.id   table1 tbl  ( [some condition] , tbl.id = [a single id number]) or ( not [some condition] , tbl.id in ( select tbl2.id                                            table2 tbl2                                           [some other condition]) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -