Knowledgebase
Stonefield Query Home > Stonefield Help Desk > Knowledgebase

Search help:


Handling Tables with the Same Names in Different Databases

Solution

Applies to:

  • Stonefield Query SDK

Stonefield Query doesn't support more than one table with the same name even if they're in different databases. (For the purposes of this article, let's call the tables MyTable and the databases Database1 and Database2.) When you add a second database to the data dictionary, you'll get a message that MyTable exists in Database1 and asks if you want to move it. If you choose yes, MyTable is removed from Database1 and exists only in Database2.

To handle this situation, do the following:

  • Change the name of MyTable in Database1 in the data dictionary (not in the actual database) to something like MyTable1 so it isn't seen as a duplicate.
  • Add the second database or refresh the data dictionary if you already added it.
  • You should now have a MyTable table in Database2. Rename it to something else such as MyTable2.
  • Rename the one in Database1 back to MyTable.
  • For MyTable2, click the Create Data Access Script link and enter the following for the code for that script:
lparameters toApplication as SQApplication, toDatabase as Database, tcSelect, tcCursor
local lcSelect
lcSelect = strtran(tcSelect, 'from MyTable2', 'from MyTable MyTable2', -1, -1, 1)
return not empty(toDatabase.ExecuteSQLStatement(lcSelect, , tcCursor))

(Of course, substitute "MyTable" and "MyTable2" with the proper two names.)

 
Was this article helpful? yes / no
Related articles Improving the Performance of Calculated Fields and Formulas
Article details
Article ID: 29
Category: How Do I... ?
Rating (Votes): Article rated 2.9/5.0 (23)

 
« Go back