dongshuzui0335 2016-08-31 01:51
浏览 453
已采纳

使用CloudSQL进行更新的SQL语言的Golang Gorm db.raw无法正常工作?

I have this SQL query, which in isolation works fine with 2 rows affected absolutely fine

update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > 0

But when I try gorm's execution variant statements in golang i.e.

err := h.db.Raw("update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > ? ", 0).Error

OR

numRecsToProcess := h.db.Raw("update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > ? ", 0).RowsAffected

None of these update statements are affecting any change in underlying DB. Is there something I am missing from Gorm usage functionality ?

  • 写回答

1条回答 默认 最新

  • dtgj8529 2016-08-31 07:02
    关注

    Try h.db.Exec instead of h.db.Raw.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题