Fixed sql parameters for postgres compatibility