On Nov 5, 2011, at 3:57 PM, Brandon Phelps wrote: > Can anyone point me in the right direction for keeping a connection to my > database opened? > > The script I need to write will run 24/7 executing a postgresql stored > procedure which inserts records into the database. The problem I think I > might have is using a standard procedural syntax of: > > Open connection > Loop > Call stored procedure/function > > ...if my connection gets interrupted somewhere during the loop any subsequent > iterations will obviously fail, so I need a way of reconnecting to the > database should the need arise. Basically something like this (I'm just not > sure how to actually code this):
Why not just open a database connection, run the procedure and close it again? : Loop open db run proc close db End loop ? If the connection is staying open long enough to get stale and be disconnected, then you shouldn't be running into timing issues. -- Bruce Johnson University of Arizona College of Pharmacy Information Technology Group Institutions do not have opinions, merely customs