I'd convert it to pure SQL code with regards to the database SELECT/UPDATE/INSERT INTO stuff and use the DB*() UDFs. Might lead to cleaner code.
_________________________
There are two types of vessels, submarines and targets.