DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: table name in cursor statement from another table row

Hybrid View

  1. #1
    Join Date
    Sep 2000
    Location
    Chennai, India
    Posts
    865

    table name in cursor statement from another table row

    Hi

    Is it possible to DECLARE a cursor where the FROM clause should have a table name from another table row?

    Thanks.

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Like this?

    SELECT * FROM mytable
    WHERE c1 IN (SELECT c1 FROM myothertable);

    or like this?

    SELECT * FROM mytable
    WHERE c1 = (SELECT c1 FROM myothertable WHERE c2 = 'AAA');

    Please give a code example to describe what you are looking for.

  3. #3
    Join Date
    Sep 2000
    Location
    Chennai, India
    Posts
    865
    Originally posted by gandolf989

    Please give a code example to describe what you are looking for.
    Hi

    Thanks for your reply.

    However, what I'm looking for is the following:

    Table A consists of 201 rows, each row consisting of "table names". Of course, table A has a key with which I can refer to each row.

    The requirement is to query the columns of "table names" rows of table A using the key, i.e.,

    Table A:
    col 1 col 1
    ----- -----
    1 table b
    2 table c
    3 table d
    .
    .
    .

    cursor c1 is
    select col1 from tablea;

    cursor c2 is select col2oftableb, col3oftableb
    from tableb; (this tableb in the from clause will/need be dynamic, depending on what is in table A.)

    Is this possible ? Or should we go for hard coding in many programs and using some CASE structure to call each program depending on the key value passed?

    Awaiting your response.

Posting Permissions

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


Click Here to Expand Forum to Full Width