469,087 Members | 1,275 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,087 developers. It's quick & easy.

Problems with "IN"

Can someeone help! This works:

SELECT * FROM sometable
WHERE 1 IN (1, 2, 3) ;

But if I want something like this:

s_mylist VARCHAR2(20) := '1, 2, 3';

SELECT * FROM sometable
WHERE 1 IN ( s_mylist ) ;

It doesn't work. Can't I do this?

Thanks
Lisa
Jul 19 '05 #1
4 2246

You can allways ask tom at:

http://asktom.oracle.com/pls/ask/f?p...950_P8_DISPLA-
YID,F4950_P8_CRITERIA:110612348061,
--
Posted via http://dbforums.com
Jul 19 '05 #2
"Lisa S." <lj******@vac-acc.gc.ca> wrote in message
news:ba**************************@posting.google.c om...
Can someeone help! This works:

SELECT * FROM sometable
WHERE 1 IN (1, 2, 3) ;

But if I want something like this:

s_mylist VARCHAR2(20) := '1, 2, 3';

SELECT * FROM sometable
WHERE 1 IN ( s_mylist ) ;

It doesn't work. Can't I do this?

Thanks
Lisa


It does not work because s_mylist is one thing the string '1, 2, 3' instead
of
where 1 in (1,2,3)
Also you are comparing numbers and strings - not good. compare numbers and
numbers.
Jim
Jul 19 '05 #3
"Jim Kennedy" <kennedy-down_with_spammers@no_spam.comcast.net> wrote in message news:<WKmjb.782313$Ho3.208508@sccrnsc03>...
"Lisa S." <lj******@vac-acc.gc.ca> wrote in message
news:ba**************************@posting.google.c om...
Can someeone help! This works:

SELECT * FROM sometable
WHERE 1 IN (1, 2, 3) ;

But if I want something like this:

s_mylist VARCHAR2(20) := '1, 2, 3';

SELECT * FROM sometable
WHERE 1 IN ( s_mylist ) ;

It doesn't work. Can't I do this?

Thanks
Lisa


It does not work because s_mylist is one thing the string '1, 2, 3' instead
of
where 1 in (1,2,3)
Also you are comparing numbers and strings - not good. compare numbers and
numbers.
Jim


Hi Jim

Sorry, I guess I wasn't clear - What we are trying to do is to format
a string with the 'IN' items to check elsewhere and pass it into the
stored procedure. I guess my question is - can't I use a variable with
the 'IN' Operator ?
Thanks
Lisa
Jul 19 '05 #4

"Lisa S." <lj******@vac-acc.gc.ca> wrote in message
news:ba**************************@posting.google.c om...
"Jim Kennedy" <kennedy-down_with_spammers@no_spam.comcast.net> wrote in

message news:<WKmjb.782313$Ho3.208508@sccrnsc03>...
"Lisa S." <lj******@vac-acc.gc.ca> wrote in message
news:ba**************************@posting.google.c om...
Can someeone help! This works:

SELECT * FROM sometable
WHERE 1 IN (1, 2, 3) ;

But if I want something like this:

s_mylist VARCHAR2(20) := '1, 2, 3';

SELECT * FROM sometable
WHERE 1 IN ( s_mylist ) ;

It doesn't work. Can't I do this?

Thanks
Lisa


It does not work because s_mylist is one thing the string '1, 2, 3' instead of
where 1 in (1,2,3)
Also you are comparing numbers and strings - not good. compare numbers and numbers.
Jim


Hi Jim

Sorry, I guess I wasn't clear - What we are trying to do is to format
a string with the 'IN' items to check elsewhere and pass it into the
stored procedure. I guess my question is - can't I use a variable with
the 'IN' Operator ?
Thanks
Lisa

Not that way. go to asktom.oracle.com and do a search. You will find
something there that will help you.
Jim
Jul 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Paul Miller | last post: by
4 posts views Thread by Marcin Dobrucki | last post: by
43 posts views Thread by markryde | last post: by
6 posts views Thread by Chris Stankevitz | last post: by
9 posts views Thread by Robbie Hatley | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.