From: Aaron Bono <postgresql@aranya.com>
To: Michael Fuhr <mike@fuhr.org>
Cc: Penchalaiah P. <penchalaiahp@infics.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: hi let me know the solution to this question
Date: Tue, 18 Jul 2006 10:54:12 -0500
Message-ID: <bf05e51c0607180854m48d83301ldc74d4d838c1a42f@mail.gmail.com> (raw)
In-Reply-To: <20060718053442.GA9694@winnie.fuhr.org>
References: <A70AE049E81A6A40879D5DC0AC8C38C906B08220@venus.infics.com>
<20060718053442.GA9694@winnie.fuhr.org>
On 7/18/06, Michael Fuhr <mike@fuhr.org> wrote:
>
> On Tue, Jul 18, 2006 at 10:46:29AM +0530, Penchalaiah P. wrote:
> > Can u let me know if at all any system defined variable exists to check
> > whether insert , update , and delete is successfully executed in a
> > stored procedure........
> >
> > So that I can perform some steps based on the result of execution if
> > possible please send me the sample code...............
>
> Depending on what you mean by "successfully executed," see "Obtaining
> the Result Status" or "Trapping Errors" in the PL/pgSQL documentation
> (error trapping is available in 8.0 and later).
>
>
> http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTIC...
>
> http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPIN...
OK, this question got me wondering: is there a way to determine, in a
function/stored procedure, the number of rows that were
inserted/updated/deleted?
For example, the following does NOT work but shows what I am trying to
achieve:
CREATE OR REPLACE FUNCTION "public"."test_fn" () RETURNS VOID AS
'
DECLARE
mycount INTEGER;
BEGIN
-- This assignment will not work be I want something like it
-- so I can count the number of records updated.
mycount := EXECUTE
''update mytable '' ||
''mycolumn = 1 '' ||
''WHERE '' ||
'' mycolumn = 2 ''
;
RAISE NOTICE ''count = %'', mycount;
RETURN;
END;
'
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
I could not find any documentation about getting the count of updates but
when you run the update by itself, PostgreSQL reports the number of records
updated so I have to believe the information is available somewhere.
Thanks,
Aaron
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.com
==================================================================
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: postgresql@aranya.com, mike@fuhr.org, penchalaiahp@infics.com
Subject: Re: hi let me know the solution to this question
In-Reply-To: <bf05e51c0607180854m48d83301ldc74d4d838c1a42f@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox