dbTalk Databases Forums  

Using string variables in Select statements

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Using string variables in Select statements in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
okumura-mikiop@jvc-victor.jp
 
Posts: n/a

Default Using string variables in Select statements - 05-01-2008 , 10:07 AM






I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.


Reply With Quote
  #2  
Old   
DA Morgan
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-01-2008 , 11:30 AM






okumura-mikiop (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
There is a demo of how to do it in Morgan's Library at www.psoug.org
Click on Morgan's Library under Resources on the left.
Click on Conditions
Scroll down to "Complex IN Demo."

Some of what it demos is what does NOT work so run the complete demo
and then use what works.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #3  
Old   
DA Morgan
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-01-2008 , 11:30 AM



okumura-mikiop (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
There is a demo of how to do it in Morgan's Library at www.psoug.org
Click on Morgan's Library under Resources on the left.
Click on Conditions
Scroll down to "Complex IN Demo."

Some of what it demos is what does NOT work so run the complete demo
and then use what works.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #4  
Old   
DA Morgan
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-01-2008 , 11:30 AM



okumura-mikiop (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
There is a demo of how to do it in Morgan's Library at www.psoug.org
Click on Morgan's Library under Resources on the left.
Click on Conditions
Scroll down to "Complex IN Demo."

Some of what it demos is what does NOT work so run the complete demo
and then use what works.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #5  
Old   
DA Morgan
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-01-2008 , 11:30 AM



okumura-mikiop (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
There is a demo of how to do it in Morgan's Library at www.psoug.org
Click on Morgan's Library under Resources on the left.
Click on Conditions
Scroll down to "Complex IN Demo."

Some of what it demos is what does NOT work so run the complete demo
and then use what works.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
  #6  
Old   
William Robertson
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-03-2008 , 02:22 AM



On May 1, 4:07 pm, okumura-mik... (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
http://tkyte.blogspot.com/2006/06/varying-in-lists.html
http://www.williamrobertson.net/docu...separated.html


Reply With Quote
  #7  
Old   
William Robertson
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-03-2008 , 02:22 AM



On May 1, 4:07 pm, okumura-mik... (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
http://tkyte.blogspot.com/2006/06/varying-in-lists.html
http://www.williamrobertson.net/docu...separated.html


Reply With Quote
  #8  
Old   
William Robertson
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-03-2008 , 02:22 AM



On May 1, 4:07 pm, okumura-mik... (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
http://tkyte.blogspot.com/2006/06/varying-in-lists.html
http://www.williamrobertson.net/docu...separated.html


Reply With Quote
  #9  
Old   
William Robertson
 
Posts: n/a

Default Re: Using string variables in Select statements - 05-03-2008 , 02:22 AM



On May 1, 4:07 pm, okumura-mik... (AT) jvc-victor (DOT) jp wrote:
Quote:
I am attempting to use a variable in the WHERE clause of a SELECT statement.
How would one pass a value for an IN statement, ie.

SELECT *
FROM inventory
WHERE color IN ('red','green')

If I replaced the last line with

WHERE color IN (v_color)

How would I set it?

v_color := '"red","green"'

doesn't work.
http://tkyte.blogspot.com/2006/06/varying-in-lists.html
http://www.williamrobertson.net/docu...separated.html


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.