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

Thread: variable

  1. #1
    Join Date
    Aug 2000
    Posts
    19

    Question

    Hi,

    I have a question. I am writing a script in which I am performing numerous queries on either a local database or a remote one. Hence, I utilize the @.world syntax. For an example, I select the row count of numerous tables on one database and then do so on the remote database in order to compare the row counts later on in the script. Thus, I may use the following syntax:

    select count(*) from table1@DB1.world;
    select count(*) from table2@DB1.world;

    select count(*) from table1@DB2.world;
    select count(*) from table2@DB2.world;

    Now, I am trying to figure out a way to read into the database name and its .world extension into a variable so I don't have to keep specifiying whether it is DB1.world or DB2.world. Hence, I can use a variable such as WHAT_DB and it will be dynamically assigned either the local database identifier, DB1.world or the remote database identifier DB2.world. Hence, I can use the following syntax to specify on which database the query will be performed:

    set WHAT_DB := DB1.world
    select count(*) from table!@WHAT_DB;

    However, I don't know how to create a variable and read the 'DB1.world' or the 'DB2.world' into it and then use the variable properly in a query which will allow it to call the proper database name and identifier.

    I hope that makes sense. Can anyone help?

    Thanks,
    Zoey

  2. #2
    Join Date
    Jul 2000
    Posts
    521
    why cann't you use dynamic (native) sql ?
    svk

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