I have some code that needs to update 2 separate databases with user credentials. The first database, I just use standard sql to do it.  The second database, I have to use command line scripts to update a specific table. What I'm worried about is what to do if the first update fails, or if any of the updates fail. Here's what the code looks like right now: local update_password = function(user_id, new_password, session_userid)   local user = listusers(user_id,nil)   if #user == 0 then      return false, User does not exist   else      sql = UPDATE users SET password='..new_password..', ..updatedname='..session_userid..', updateddatetime=..os.date(%Y%m%d%H%M%S)..createwhereclause(uid)      runsqlcommand(sql)       -- remove user from second db      local user = {}      user.descr, user.errtxt = opencmd({dbctrl, rm, user_id})           if not user.errtext then                      user.descr, user.errtxt = opencmd({dbctrl, add, user_id, new_password})       else            result = Unable to update cdb with new credentials         return false, result            end      if not user.errtext then                      result = User's password has been updated           else         result = Unable to update cdb with new credentials         return false, result      end        end   return true, resultendI guess I should check each step of the way to make sure that the previous sql worked.  So after updating database 1, I should do a select using the new credentials to make sure I get a result. But do you have any other suggestions to improve the reliability of this code?Thanks.
How can i make this code more robust, fail proof?
lua