Fixed a bug in db.q

No error should be raised when result is not produced.