Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to do this as a singleton select?

Re: How to do this as a singleton select?

From: Greg Akins <insomnia_at_cvzoom.net>
Date: Wed, 8 Jan 2003 14:28:53 -0500
Message-ID: <3e1c7444$1@post.usenet.com>

"Ryan Gaffuri" <rgaffuri_at_cox.net> wrote in message news:1efdad5b.0301081021.fb21748_at_posting.google.com...
> I cant remember how to do this as one select statement.
>
> SELECT TABLE_NAME
> FROM USER_TAB_COLUMNS
> WHERE TABLE_NAME = p_tableName(this is a variable passed in)
> and COLUMN_NAME = ... however, there are 4 column_names and all of
> them have to appear.
>
> I know I can do it with 4 implicit cursors and just pass the results
> to the next, but how do I do it with a subquery?
>
> SELECT column
> into v_column
> from table
> where column = 'A'
>
> select column
> into v_column2
> from table
> where column = v_column
>
> and so on...
>
>
> I know its basic, but I cant remember how to do this. Went brain dead.

select table_name
from user_tab_columns
where table_name = p_tablename
and column_name in ('A', 'B', 'C')

or

select table_name
from user_tab_columns
where table_name = p_tablename
and column_name in (select column from table where column = v_column or column = v_column2)

Is that what you were looking for?

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Received on Wed Jan 08 2003 - 13:28:53 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US