SQL select statement - a strange one!!
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: SQL select statement - a strange one!!

  1. #1
    Join Date
    Mar 2001


    Hi all,
    I'm trying to write a select statement in a LOOP that would select from a variable instead of a table, for example:
    if i have a variable called my_var contains a value 'SCHOOL_LIST' (which is a table name in the database)

    how can I write a select statement so that the below would work:

    Select schoolname from my_var;

    (the variable is being populated via a cursor)

    plse help me ..Thanks

  2. #2
    Join Date
    Aug 2000
    look at EXECUTE IMMEDIATE to execute a dynamic sql string you create at run time, as indicated in your question.

  3. #3
    Join Date
    Jan 2001
    Hey I would prefer to use ref cursors for that purpose..That will handle u r problem efficiently..


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