Implementation of feature request 1412. Creating view for empty resultset. Refactoring work on pull req 226