Re: SE: 7.12 CLOSE DATABASE
Posted in 1999
Topics: General Discussion
Jason J. Crowther wrote: > > I'm trying to devise a scheme to close the database so a > proper (data consistant) backup can be made. > > does the CLOSE DATABASE command immediately close the > database or does it wait for current transactions to > complete? It is only safe to backup an SE database if there are NO users connected to it. The CLOSE DATABASE will disconnect that one user from the database and terminate the SQLEXEC process. You still have to worry about other users if any. Art S. Kagel
"Art S. Kagel" wrote: > It is only safe to backup an SE database if there are NO users > connected to it. Right. No contest. > The CLOSE DATABASE will disconnect that one user from > the database and terminate the SQLEXEC process. You still have to > worry about other users if any. hmm. methinks I've mistunderstood what the CLOSE DATABASE command does. so, I'm guessing I would have do something like this to assure no users: 1. CLOSE DATABASE (necessary?) 2. DATABASE <name> EXCLUSIVE 3. do backup... 4. CLOSE DATABASE 5. DATABASE <name> the DATABASE <name> EXCLUSIVE doesn't succeed if there are any open connections. comments, improvements welcomed. -- +- Jason J. Crowther ------------------------------------+ jason@cny.com Software Engineer Syracuse Research Corporation ATC http://atc.syrres.com +--------------------------------------------------------+
Jason J. Crowther wrote: > > "Art S. Kagel" wrote: > > > It is only safe to backup an SE database if there are NO users > > connected to it. > > Right. No contest. > > > The CLOSE DATABASE will disconnect that one user from > > the database and terminate the SQLEXEC process. You still have to > > worry about other users if any. > > hmm. methinks I've mistunderstood what the CLOSE DATABASE > command does. > > so, I'm guessing I would have do something like this to > assure no users: > > 1. CLOSE DATABASE (necessary?) > 2. DATABASE <name> EXCLUSIVE > 3. do backup... > 4. CLOSE DATABASE > 5. DATABASE <name> > > the DATABASE <name> EXCLUSIVE doesn't succeed if there are > any open connections. This is a better technique, though you might want to loop on Step 2 if it fails -- at least, give it a few tries. Step 1 is probably unnecessary. Step 5 is probably unnecessary. Normally, the process doing the backup will terminate when the backup is complete, thus allowing other processes to use the database again. Of course, if the process terminates after step 5, then the database is implicitly closed again. The DATABASE statement initiates a connection to a single database for a single process. The CLOSE DATABASE statement terminates that connection, again for a single process. Only the DATABASE EXCLUSIVE statement affects other users. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>
Jonathan Leffler wrote: > This is a better technique, though you might want to loop on Step 2 > if it fails -- at least, give it a few tries. I thought a loop would be a good idea too. > The DATABASE statement initiates a connection to a single database > for a single process. The CLOSE DATABASE statement terminates that > connection, again for a single process. Only the DATABASE EXCLUSIVE > statement affects other users. ok. since you happen to 'Guardian of DBD::Informix', which I just happen to be using, is it possible to do 'DATABASE <name> EXCLUSIVE' through DBI? (or do I have to do some custom esql?) thanks for the help! ;-) -- +- Jason J. Crowther ------------------------------------+ jason@cny.com Software Engineer Syracuse Research Corporation ATC http://atc.syrres.com +--------------------------------------------------------+