pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
hi let me know the solution to this question
5+ messages / 4 participants
[nested] [flat]

* hi let me know the solution to this question
@ 2006-07-18 05:16  Penchalaiah P. <penchalaiahp@infics.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Penchalaiah P. @ 2006-07-18 05:16 UTC (permalink / raw)
  To: pgsql-sql


Hi good morning all........



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...............

Thanks  &  Regards

Penchal reddy | Software Engineer          

Infinite Computer Solutions | Exciting Times...Infinite Possibilities...


SEI-CMMI level 5 | ISO 9001:2000

IT SERVICES | BPO


Telecom | Finance | Healthcare | Manufacturing | Energy & Utilities |
Retail & Distribution | Government


Tel +91-80-5193-0000(Ext:503)| Fax  +91-80-51930009 | Cell No
+91-9980012376|www.infics.com         

Information transmitted by this e-mail is proprietary to Infinite
Computer Solutions and/ or its Customers and is intended for use only by
the individual or entity to which it is addressed, and may contain
information that is privileged, confidential or exempt from disclosure
under applicable law. If you are not the intended recipient or it
appears that this mail has been forwarded to you without proper
authority, you are notified that any use or dissemination of this
information in any manner is strictly prohibited. In such cases, please
notify us immediately at info.in@infics.com and delete this mail from
your records.





Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this email from your records.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: hi let me know the solution to this question
@ 2006-07-18 05:34  Michael Fuhr <mike@fuhr.org>
  parent: Penchalaiah P. <penchalaiahp@infics.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Michael Fuhr @ 2006-07-18 05:34 UTC (permalink / raw)
  To: Penchalaiah P. <penchalaiahp@infics.com>; +Cc: pgsql-sql

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...

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: hi let me know the solution to this question
@ 2006-07-18 15:54  Aaron Bono <postgresql@aranya.com>
  parent: Michael Fuhr <mike@fuhr.org>
  0 siblings, 1 reply; 5+ messages in thread

From: Aaron Bono @ 2006-07-18 15:54 UTC (permalink / raw)
  To: Michael Fuhr <mike@fuhr.org>; +Cc: Penchalaiah P. <penchalaiahp@infics.com>; pgsql-sql

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
==================================================================

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: hi let me know the solution to this question
@ 2006-07-18 16:44  Bricklen Anderson <banderson@presinet.com>
  parent: Aaron Bono <postgresql@aranya.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Bricklen Anderson @ 2006-07-18 16:44 UTC (permalink / raw)
  To: Aaron Bono <postgresql@aranya.com>; +Cc: pgsql-sql

Aaron Bono wrote:
> On 7/18/06, *Michael Fuhr* <mike@fuhr.org <mailto:mike@fuhr.org>> wrote:
<snip>
>     http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTIC...
<snip>
>  
> 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?
<snip>
> 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
> 
Look for the section entitled "36.6.6. Obtaining the Result Status" on 
the link that Michael Fuhr supplied (above). Is that what you are 
looking for?



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: hi let me know the solution to this question
@ 2006-07-18 18:35  Aaron Bono <postgresql@aranya.com>
  parent: Bricklen Anderson <banderson@presinet.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Aaron Bono @ 2006-07-18 18:35 UTC (permalink / raw)
  To: Bricklen Anderson <banderson@presinet.com>; +Cc: pgsql-sql

On 7/18/06, Bricklen Anderson <banderson@presinet.com> wrote:
>
> Aaron Bono wrote:
> > On 7/18/06, *Michael Fuhr* <mike@fuhr.org <mailto:mike@fuhr.org>> wrote:
> <snip>
> >
> http://www.postgresql.org/docs/8.1/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTIC...
> <snip>
> >
> > 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?
> <snip>
> > 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
> >
> Look for the section entitled "36.6.6. Obtaining the Result Status" on
> the link that Michael Fuhr supplied (above). Is that what you are
> looking for?
>


Ah yes, I missed the part on ROW_COUNT .  That should do it.

==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
==================================================================

^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2006-07-18 18:35 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-07-18 05:16 hi let me know the solution to this question Penchalaiah P. <penchalaiahp@infics.com>
2006-07-18 05:34 ` Michael Fuhr <mike@fuhr.org>
2006-07-18 15:54   ` Aaron Bono <postgresql@aranya.com>
2006-07-18 16:44     ` Bricklen Anderson <banderson@presinet.com>
2006-07-18 18:35       ` Aaron Bono <postgresql@aranya.com>

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