Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Getting a count from an update



Newbie question here: I want to be able to capture the count of the number of rows updated from an update command within SQL. I know that psql prints out the result, I want to grab it within a function. The update is a simple "UPDATE tablename SET col = value WHERE othercol = otherval;", which will generally update many dozens or hundreds of rows. Currently I'm doing a select before doing the update, but since I'm doing a select count(*) I can't add a 'for update' to the end and lock the rows. Is there a better way to do this?

Brian




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group