I'd rather recode the inventory script to use pure SQL for database interaction as it will make the programming logic and the debugging simpler. You can then also take advanged of the various database UDFs.
_________________________
There are two types of vessels, submarines and targets.