From: | "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk> |
---|---|
To: | Pgsql-General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: rowcount |
Date: | 2002-05-01 21:22:14 |
Message-ID: | Pine.LNX.4.21.0205012219510.9945-100000@ponder.fairway2k.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 1 May 2002, Joe Conway wrote:
> Anna Dorofiyenko wrote:
> > Hello, list.
> >
> > How can I get in PL/pgSQL number of rows affected by insert/update?
> >
> >
> >
> > I'm looking to do something like:
> >
> > insert into...
> >
> > If rowcount>0
> >
> > then ...
> >
>
> See section 23.5.5 at:
> http://www.postgresql.org/idocs/index.php?plpgsql-statements.html
>
> Here's the part you want:
> 23.5.5. Obtaining result status
>
> GET DIAGNOSTICS variable = item [ , ... ] ;
>
> This command allows retrieval of system status indicators. Each item is
> a keyword identifying a state value to be assigned to the specified
> variable (which should be of the right data type to receive it). The
> currently available status items are ROW_COUNT, the number of rows
> processed by the last SQL query sent down to the SQL engine; and
> RESULT_OID, the Oid of the last row inserted by the most recent SQL
> query. Note that RESULT_OID is only useful after an INSERT query.
>
INSERT INTO <table> and not into a view, using a rule to do the real inserting,
fwiw.
--
Nigel J. Andrews
Director
---
Logictree Systems Limited
Computer Consultants
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Bierman | 2002-05-01 21:51:52 | Re: Mac OS X: system shutdown prevents checkpoint |
Previous Message | Jakub Ouhrabka | 2002-05-01 20:59:21 | Re: FATAL: stuck spinlock |