Technical Tips

Switching file systems

Switching file systems Each time a file is opened, the file system identified by the filename_HOST configuration variable (if present) or the DEFAULT_HOST variable is used. You can change the value of these variables in your code by including:

SET ENVIRONMENT "filename_HOST" TO filesystem 

or

SET ENVIRONMENT "DEFAULT_HOST" TO filesystem 

just before you open the file. SET ENVIRONMENT thus enables you to change file systems during the execution of your program. The filesystem value for Informix is “Informix”. The value for Vision is “Vision”.

If you change to the Informix file system in the midst of a program, be sure to specify the database to be used:

SET ENVIRONMENT "DEFAULT_HOST" TO "INFORMIX" 

SET ENVIRONMENT "DATABASE" TO "STORES"

Note that the database cannot be changed if there are tables open in the active database. Be sure to close all tables before making a change.

Remember that SET ENVIRONMENT is not the typical way to specify a file system. Normally the file system is designated in the runtime configuration file and is not changed in the COBOL program.