Add an error check for creating a result table of select