There are a library of UDFs that can handle database transactions - look for DBConnOpen(), DBExecuteSQL(), and DBConnClose(), those should let you do what you're thinking of doing.