fix getLastInsertId() for postgres

This fix should be working, when postgresql version >= 8.2.