refactor update/insert query to support additional features

  - added logic to handle corner cases regarding autoIncrement values
  - added support for OUTPUT variables (mssql)
  - added support for identity wrapping (related to point 1)