Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 3
    What a fantastic answer - should be framed. Commented Feb 3, 2020 at 21:47
  • Thank you so much. I ended took the update...from..locks... solution as I my function was a counter increment which updated another table. Worked great once I added the locks and the function in the from. Thanks so much. Commented May 27, 2020 at 22:22
  • @NickBarnes Does CTID solution guarantee Update will happen in same sequence as the array is created in? I understand only locks were acquired in the same sequence, unless ANY guarantee its a POP data structure for update where clause... or am i missing something Commented Nov 17, 2020 at 14:30
  • 1
    @Laukik: No, I don't think there are ever any guarantees about the update order - if there were, we could just use that to control the lock order, and we wouldn't need the SELECT FOR UPDATE. If you really need this guarantee, I think you'll need to use the cursor. Commented Nov 17, 2020 at 15:55
  • 1
    beautiful! it is sometimes needed to return whatever you have just updated, and that can be achieved using ... returning ID Commented Apr 11, 2022 at 11:01