changed queries for compatibility with postgresql

Created by  Rob Vermaas  on April 28, 2009
K4C6DNSM7ARO6I24TEXIAHJ4XM7P3MXTXEPXKGDEAKALBL4RJQVAC
Change contents