2016-09-26 05:21
浏览 52


I am using postgres as my database and https://github.com/lib/pq as library. I am updating a record using prepared statement

stmt, _:= db.Prepare("UPDATE account set status='deleted' where id= $1")   
defer stmt.Close()
result, _:= stmt.Exec(accountId)
success, _:= result.RowsAffected()

And I noticed that the even if the row is already updated with the status=deleted update query always returns success=1. Is there any way we can differentiate between already updated row and not yet updated row?

图片转代码服务由CSDN问答提供 功能建议

我正在使用postgres作为我的数据库和 https://github.com/lib/pq 作为库。 我正在使用准备好的语句更新记录

  stmt,  _:= db.Prepare(“更新帐户集状态=“已删除”,其中id = $ 1”)
defer stmt.Close()
result,_:= stmt.Exec(accountId)
success,_:= result.RowsAffected  ()

我注意到,即使该行已使用status = deleted update查询更新,也总是返回success = 1。 有什么方法可以区分已经更新的行和尚未更新的行?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题