in reply to error in sql query while using DBI

Rather than having all of the "or die ..." clauses, it would be simpler to use RaiseError on the connect(). You would also get the benefit of error checking on the fetch statement (e.g. deadlocks?).