Is there a way of specify database name alias in the same server?
Posted in 2003
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues, Versions, Editions & End-of-Life
Scenario: IDS 9.40 4GL RDS application Linux Redhat 7.3 A unique database server (INFORMIXSERVER=myserver) 3 datatabases with identical schema in the same server: mydatabasecompany1 mydatabasecompany2 mydatabasecompany3 In the 4GL software there are static DATABASE statements pointing to mydatabase. ie: DATABASE mydatabase Question: Is there a way to define an ALIAS for a database like this ALIAS mydatabasecompany1 AS mydatabase so that I can switch from one to another without changing thousands (OK, hundreds) of programas with static references? They come from standard engine where I can change easily DBPATH to a directory containing company1/mydatabase or company2/mydatabase Thanks in advance Mario R. Canto mcanto@4m.com.ar sending to informix-list
mcanto@4m.com.ar wrote: > > Scenario: > > IDS 9.40 > 4GL RDS application > Linux Redhat 7.3 > A unique database server (INFORMIXSERVER=myserver) > > 3 datatabases with identical schema in the same server: > mydatabasecompany1 > mydatabasecompany2 > mydatabasecompany3 > > In the 4GL software there are static DATABASE statements pointing to > mydatabase. ie: > DATABASE mydatabase > > Question: > Is there a way to define an ALIAS for a database like this > ALIAS mydatabasecompany1 AS mydatabase > so that I can switch from one to another without changing thousands (OK, > hundreds) of programas with static references? > > They come from standard engine where I can change easily DBPATH to a > directory containing company1/mydatabase or company2/mydatabase Errrr...why didn't you create separate instances? -- Ciao, The Obnoxious One "Ogni uomo mi guarda come se fossi una testa di cazzo"
mcanto@4m.com.ar wrote: > Scenario: > > IDS 9.40 > 4GL RDS application > Linux Redhat 7.3 > A unique database server (INFORMIXSERVER=myserver) > > 3 datatabases with identical schema in the same server: > mydatabasecompany1 > mydatabasecompany2 > mydatabasecompany3 > > In the 4GL software there are static DATABASE statements pointing to mydatabase. > ie: > DATABASE mydatabase > > Question: > Is there a way to define an ALIAS for a database like this > ALIAS mydatabasecompany1 AS mydatabase > so that I can switch from one to another without changing thousands (OK, > hundreds) of programas with static references? No, but there's no particular need to do so, either. > They come from standard engine where I can change easily DBPATH to a directory > containing company1/mydatabase or company2/mydatabase With multiple instances, as the noble OTC said, you could do it - by simply changing the value of INFORMIXSERVER. You do have some standard startup code that you use to do things like start log files and validate that the user is permitted to access the database, don't you? If so, you can extend it to switch the database at run time. Ideally, you modify the code so that it uses a dummy main program: MAIN DEFER INTERRUPT DEFER QUIT CALL select_runtime_database() CALL real_main_program() END MAIN This, be it noted, does not pre-select any database - that's the job for the select_runtime_database() function. The real_main_program() is your current code in MAIN/END MAIN modified so it starts FUNCTION real_main_program() and ends with END FUNCTION, and you also remove any DEFER INTERRUPT and DEFER QUIT statements. That can be done by a sed script, let alone a Perl script (which is what I'd probably use). You have to be confident that the 'mydatabase' which is used at compile time has the same structure as the operational databases. If you get that wrong, you will have (if you're lucky) fatal runtime errors (and if you're unlucky, weird corruption problems caused by modifying the wrong data). If you don't already have the standard startup code in place, now might be a very good time to add it - it is one of the things that can really save your bacon when migrating from SE to OnLine/IDS/XPS. See also my postings on this subject from a year to ten years ago, maybe even longer since the first one. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/