From: | "Leif B(dot) Kristensen" <leif(at)solumslekt(dot)org> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how do i get num of recs inserted/deleted/updated in plpgsql |
Date: | 2007-08-01 16:20:43 |
Message-ID: | 200708011820.43997.leif@solumslekt.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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/
From | Date | Subject | |
---|---|---|---|
Next Message | Joseph S | 2007-08-01 16:20:49 | Re: Linux distro |
Previous Message | Gauthier, Dave | 2007-08-01 16:14:01 | Re: how do i get num of recs inserted/deleted/updated in plpgsql |