> > Hi, > > I want to write a program that acesses two databases, > fetching data from one, writing to the other. The core code > works fine now, but i have several thoughts left: > The program shall run as WinNT Service, running every 10 > minutes or so. So the program may not "die" when it can't > connect, but just wait until the next run. > I also need some verification of the data being written to > the second DB before deleting it from the first, would a > construction like this work? > > if ($mssth->execute) { > <no error>; > } > else { > <error to log>; > }
Lars, I've written these types of things before (actually synchronizing a database entry with the NT Login information for a large scale, 24 hour facility. My suggestion is to use RaiseError and to use eval, using something like the pseudo code below: while (1) { eval { updateDatabase(); }; if ($@) { log_error() } sleep(your_time); } In updateDatabase() (or whatever) eval { connect to dbs; do your work disconnect from dbs; } It's relatively important to check the connections and if you can afford it, it's better to connect and disconnect, IMHO. Jeff