getting number of rows updated within a procedure

Поиск
Список
Период
Сортировка
Искать

getting number of rows updated within a procedure

От:
"Dan Langille" <dan@langille.org>
Дата:
I'm writing a procedure and I want to check the number of rows updated. 
  But I can't figure out how.  I know UPDATE returns "UPDATE #" but I 
don't know how to use that to get what I need.

Here's an example:

CREATE FUNCTION "test" () RETURNS int AS '
DECLARE
        v_number_of_rows int;

BEGIN
          update bigtable
          set email_confirmed = 1
          where user_group  = 1234;

-- and here, I want to know the number of rows updated
         v_number_of_rows := *what?*;

END;
' LANGUAGE 'plpgsql';


Thanks.

--
Dan Langille
The FreeBSD Diary - http://freebsddiary.org/
       FreshPorts - http://freshports.org/
     NZ Broadband - http://unixathome.org/broadband/
FAQ