Created
July 29, 2016 18:53
-
-
Save jbratu/ca073279344db057fa44a37e9747e684 to your computer and use it in GitHub Desktop.
Given a list of volumes, tables, and applications the routine will detach the existing tables, re-attach them with a different UNC, and then save the DBT file so the tables are available at next OpenInsight launch.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function CS_DETACH_ATTACH_AND_DEFINE_DBT(void) | |
/* | |
Use this routine To change the UNC prefix In the list of Tables | |
And re-save the DBT file. | |
*/ | |
*Prefixes to change from and to. Format: | |
*\\OldServer\,\\NewServer\ | |
ChangePrefixes = "" | |
ChangePrefixes<-1> = '\\192.168.222.2\,\\OBERLIN\' | |
ChangePrefixes<-1> = '\\192.168.222.1\,\\OBERLIN1\' | |
Tables = "" ;*The list of tables to detach and attach | |
*Format: | |
*UNCPath,Table,App | |
Tables<-1> = '\\192.168.222.2\REVSOFT\CSTESTDATA,PERSON_INFO_TEST,GLOBAL' | |
Declare Subroutine Set_Status, Detach_table, Attach_Table, Define_Database | |
Declare Function Get_Status | |
$Insert Logical | |
Err = '' | |
Swap ',' With @VM In ChangePrefixes | |
ChangePrefixesCount = DCOUNT(ChangePrefixes, @FM) | |
Swap ',' With @VM In Tables | |
TablesCount = DCOUNT(Tables, @FM) | |
*Loop through all Tables | |
For i = 1 To TablesCount | |
*Get one entry from the list of tables | |
Vol = Tables<i, 1> | |
Table = Tables<i, 2> | |
App = Tables<i, 3> | |
*Detach the table | |
Set_Status(0) | |
Detach_table(Table) | |
If Get_Status(err) Then | |
Debug | |
End | |
*Swap the prefix so the volume can be attached under the new path | |
For j = 1 To ChangePrefixesCount | |
OldPrefix = ChangePrefixes<j,1> | |
NewPrefix = ChangePrefixes<j,2> | |
Swap OldPrefix With NewPrefix In Vol | |
Next | |
*Do the attach | |
Set_Status(0) | |
Attach_Table(Vol, Table, App, '') | |
If Get_Status(err) Then | |
Debug | |
End | |
Next | |
*Finally define the database to save the list of tables | |
Set_Status(0) | |
Define_Database(@dbid, TRUE$, "", "") | |
If Get_Status(err) Then | |
Debug | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment