getting number of rows updated within a procedure - Mailing list pgsql-general

From Dan Langille
Subject getting number of rows updated within a procedure
Date
Msg-id 200101141019.XAA47026@ducky.nz.freebsd.org
Whole thread Raw
List pgsql-general
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/

pgsql-general by date:

Previous
From: Patricia_Leong@tecsg.com.sg
Date:
Subject: SQL command for value comparison
Next
From: Tod McQuillin
Date:
Subject: Re: where to host??