Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011

    Unanswered: Pass result set as a table name


    I have a question about whether or not it is possible to pass the value returned in an inner-select as a table name. Below is a simple example of what I am trying to do. Let's say I have a table called BASE_DATA and within that table is a column called TABLE_NAME. So let's say I have a statement as follows:

    select table_name from base_data where rownum<2

    This query returns the value EMP. I now want to select from EMP. I've tried the following:

    select * from (select table_name from base_data where rownum<2)

    But that only selects from the resultset returned by the inner-select, rather than the table name returned in the resultset. Is it possible for me to do this in a select?

    Any help is greatly appreciated.


  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    >Is it possible for me to do this in a select?
    It depends upon how "possible" is defined.
    If only SQL is to be used, then then answer is "NO".
    If PL/SQL can be used then a SELECT can be done
    read up on EXECUTE IMMEDIATE
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts