Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

subquery inside IN clause

user11936261Jul 25 2013 — edited Jul 25 2013

Hi,

Below is the block which i am trying to test in scott schema. I dont want to substute IN clause values directly.

So i have written cursor and have added in separate variable separeated by comma.

But its not working.

declare

s varchar2(1000);

s1 varchar2(1000);

v number := 0;

v1 varchar2(2000) := 'SCOTT';

j number := 0;

cursor hh

is select ename from emp;

begin

select count(*) into v from emp;

for i in hh

loop

s := s||''''||i.ename||'''';

j := j+1;

if j <> v

then s := s||',';

end if;

s1 := s1||s;

s := null;

end loop;

dbms_output.put_line(S1);

case when v1 in (s1)

then dbms_output.put_line('Y');  else dbms_output.put_line('N');

end case;

end;

Please let me know is there any other way to solve this.

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 22 2013
Added on Jul 25 2013
3 comments
481 views