added a null check.
added code to receive SQL statement started from 'select'.