Re: Changing the database at runtime
Posted in 1996
Mike Aubury wrote: > > In article: <Dpnp1r.85K@cix.compulink.co.uk> > onlinedbc@cix.compulink.co.uk ("Malcolm Weallans") writes: > > > > Mike is basically correct. But you do need source! and the > database > > defined at the beginning of the MAIN module MUST exist. > Otherwise you > > get a -329 Database not found or no system permission > error. > > > > Malcolm Weallans > > Online Database Consultancy > > Phone 01628-72154 > > Fax 01628-37463 > > CIX - onlinedbc > Just to make something clear - the DATABASE dbname at the > top of the module is used for two purposes > 1) to set the working database > 2) used for schemas for RECORD LIKE... > > If you dont have any RECORD LIKE definitions then > you dont even need the "database dbname" at the top! Just to make this even clearer (I hope): only the "main" routine opens a database according to the database statement at the top of that module. No database is opened at program start if this is omitted, but they can be opened later before they are used. The database statement at the top of all modules other than the one containing the "main" routine are only used for RECORD LIKE definitions. They do not open a database. An additional note: A program may be developed for multiple identically structured databases, for example a development database and a production database, or multiple identical production databases. By omitting the database statement at the top of the main module, you can avoid the overhead of having to close that database and reopen another. The appropriate database can be set with an environment variable or whatever, and opened somewhere with a prepared database command or a connect command (using Esql/c). Best wishes, ------------------------------------------------------------ John H. Frantz Power-4gl: Extending the Informix-4gl user interface http://www.strengur.is/~frantz/pow4gl.html