Thread: hi let me know the solution to this question

hi let me know the solution to this question

From
"Penchalaiah P."
Date:
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Hi good morning all……..</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Can u let me know if at all any system defined variable exists to check whether insert , update ,
anddelete is successfully executed in a stored procedure……..</span></font><p class="MsoNormal"><font face="Arial"
size="2"><spanstyle="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">So that I can perform some steps based on the  result of execution if possible please send me the
samplecode……………</span></font><p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><font
color="navy"face="Tahoma" size="1"><span style="font-size:8.0pt;font-family:Tahoma; 
color:navy;font-weight:bold">Thanks  &  Regards</span></font><font color="navy"><span
style="color:navy"></span></font></b><pclass="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><font
color="navy"face="Tahoma" size="1"><span style="font-size:8.0pt;font-family:Tahoma; 
color:navy;font-weight:bold">Penchal reddy </span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold"> Software Engineer           </span></font><font color="navy"><span
style="color:navy"></span></font></b><pclass="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><font
color="navy"face="Tahoma" size="1"><span style="font-size:8.0pt;font-family:Tahoma; 
color:navy;font-weight:bold">Infinite Computer Solutions </span></font></b><b><font color="red" face="Tahoma"
size="1"><spanstyle="font-size:8.0pt;font-family:Tahoma; 
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold"> Exciting Times…Infinite Possibilities... </span></font><font color="navy"><span
style="color:navy"></span></font></b><pclass="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><font
color="navy"face="Tahoma" size="1"><span style="font-size:8.0pt;font-family:Tahoma; 
color:navy;font-weight:bold">SEI-CMMI level 5 </span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:red;font-weight:bold">| </span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;
font-weight:bold">ISO 9001:2000</span></font><font color="navy"><span style="color:navy"></span></font></b><p
class="MsoNormal"style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:navy;font-weight:bold">IT SERVICES </span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold">
BPO                                                                                                                                                                          
</span></font><fontcolor="navy"><span style="color:navy"></span></font></b><p class="MsoNormal"
style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><fontcolor="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:navy;font-weight:bold">Telecom </span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold"> </span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;font-weight:bold">Finance</span></font></b><b><font color="red"
face="Tahoma"size="1"><span style="font-size: 
8.0pt;font-family:Tahoma;color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma"
size="1"><spanstyle="font-size:8.0pt;font-family:Tahoma; 
color:navy;font-weight:bold"> </span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;
font-weight:bold">Healthcare </span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:red;
font-weight:bold">| </span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;font-weight:bold">Manufacturing</span></font></b><b><font
color="red"face="Tahoma" size="1"><span style="font-size: 
8.0pt;font-family:Tahoma;color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma"
size="1"><spanstyle="font-size:8.0pt;font-family:Tahoma; 
color:navy;font-weight:bold"> </span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;
font-weight:bold">Energy & Utilities </span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold"> </span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;font-weight:bold">Retail& Distribution
</span></font></b><b><fontcolor="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:red;font-weight:bold">|</span></font></b><b><fontcolor="navy"
face="Tahoma"size="1"><span style="font-size:8.0pt;font-family:Tahoma; 
color:navy;font-weight:bold"> </span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;
font-weight:bold">Government                                                        </span></font><font
color="navy"><spanstyle="color:navy"></span></font></b><p class="MsoNormal"
style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><fontcolor="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:navy;font-weight:bold">Tel +91-80-5193-0000(Ext:503)</span></font></b><b><font color="red" face="Tahoma"
size="1"><spanstyle="font-size:8.0pt;font-family:Tahoma; 
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold"> Fax  +91-80-51930009 </span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold"> Cell No  +91-9980012376</span></font></b><b><font color="red" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:red;font-weight:bold">|</span></font></b><b><font color="navy" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:navy;
font-weight:bold">www.infics.com</span></font></b><b><font color="black" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:black;
font-weight:bold">          </span></font><font color="navy"><span style="color:navy"></span></font></b><p
class="MsoNormal"style="mso-margin-top-alt:auto;margin-bottom:5.0pt"><b><font color="gray" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:gray;font-weight:bold">Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and/
orits Customers and is intended for use only by the individual or entity to which it is addressed, and may contain
informationthat is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended
recipientor it appears that this mail has been forwarded to you without proper authority, you are notified that any use
ordissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately
at</span></font></b><b><fontcolor="black" face="Tahoma" size="1"><span style="font-size:8.0pt;font-family:Tahoma; 
color:black;font-weight:bold"> </span></font></b><b><u><font color="gray" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;color:gray;
font-weight:bold">info.in@infics.com </span></font></u></b><b><font color="gray" face="Tahoma" size="1"><span
style="font-size:8.0pt;font-family:Tahoma;
color:gray;font-weight:bold">and delete this mail from your records.</span></font><font color="navy"><span
style="color:navy"></span></font></b><pclass="MsoNormal"><font face="Times New Roman" size="3"><span style="font-size: 
12.0pt"> </span></font></div><table><tr><td bgcolor="#ffffff"><font color="#000000">Information transmitted by this
e-mailis proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the
individualor the entity to which it is addressed, and may contain information that is privileged, confidential or
exemptfrom disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been
forwardedto you without proper authority, you are notified that any use or dissemination of this information in any
manneris strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this email
fromyour records.<br /></font></td></tr></table> 

Re: hi let me know the solution to this question

From
Michael Fuhr
Date:
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-DIAGNOSTICS
http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

-- 
Michael Fuhr


Re: hi let me know the solution to this question

From
"Aaron Bono"
Date:
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-DIAGNOSTICS
http://www.postgresql.org/docs/8.1/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

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

Re: hi let me know the solution to this question

From
Bricklen Anderson
Date:
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-DIAGNOSTICS
<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?


Re: hi let me know the solution to this question

From
"Aaron Bono"
Date:
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-DIAGNOSTICS
<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
==================================================================