Update gpgsql queries

fixes #927
Merge pull request #932 from cyclops1982/927

Update gpgsql queries