Re: how do i get num of recs inserted/deleted/updated in plpgsql - Mailing list pgsql-general

From Leif B. Kristensen
Subject Re: how do i get num of recs inserted/deleted/updated in plpgsql
Date
Msg-id 200708011820.43997.leif@solumslekt.org
Whole thread Raw
In response to how do i get num of recs inserted/deleted/updated in plpgsql  ("Gauthier, Dave" <dave.gauthier@intel.com>)
List pgsql-general
On Wednesday 1. August 2007 18:05, Gauthier, Dave wrote:
>Looking to capture the total number of records affected with
>insert/delete/update from within a plpgsql (v7.4 on linux).  Would be
>nice to have this in an integer.

http://www.varlena.com/GeneralBits/23.php

8<-----
 How many rows were affected?
[GENERAL] pl-pgsql question     24-Apr-2003

In pl/pgsql, you can find out how many rows were affected by a statement
by using GET DIAGNOSTICS immediately after the statement in question.

This is how the statement is used with ROW_COUNT. With ROW_COUNT, the
statement before the GET DIAGNOSTICS must be an INSERT, UPDATE or
DELETE.

    DECLARE
        rowcount    integer;
        ...
    BEGIN
        [INSERT | UPDATE | DELETE] ....
        GET DIAGNOSTICS rowcount = ROW_COUNT;

The GET DIAGNOSTICS statement can also be used with LAST_OID to fetch
the OID of the last INSERT statement, if it had an OID. If the table
did not have OIDS, it returns 0.

Contributors: Vilson farias vilson.farias at digitro.com.br, Darren
Ferguson darren at crystalballinc.com, Dennis Gearon gearond at cvc.net
8<-----
--
Leif Biberg Kristensen | Registered Linux User #338009
http://solumslekt.org/ | Cruising with Gentoo/KDE
My Jazz Jukebox: http://www.last.fm/user/leifbk/

pgsql-general by date:

Previous
From: "Gauthier, Dave"
Date:
Subject: Re: how do i get num of recs inserted/deleted/updated in plpgsql
Next
From: Joseph S
Date:
Subject: Re: Linux distro