From skarthi98@hotmail.com Sat Apr 7 17:33:24 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id A01179FB4F4; Sat, 7 Apr 2007 14:33:24 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 39285-04; Sat, 7 Apr 2007 14:33:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from bay0-omc3-s36.bay0.hotmail.com (bay0-omc3-s36.bay0.hotmail.com [65.54.246.236]) by postgresql.org (Postfix) with ESMTP id A41859FB4E5; Sat, 7 Apr 2007 14:33:20 -0300 (ADT) Received: from BAY131-W18 ([65.55.136.53]) by bay0-omc3-s36.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.2668); Sat, 7 Apr 2007 10:33:19 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_bb7ede35-5096-490b-96b5-fa0e9534ea97_" X-Originating-IP: [69.181.160.236] From: Karthikeyan Sundaram To: postgres admin , postgres sql Subject: rowcount function in postgres??? Date: Sat, 7 Apr 2007 10:33:19 -0700 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 07 Apr 2007 17:33:19.0629 (UTC) FILETIME=[D54213D0:01C7793A] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.784 tagged_above=0 required=5 tests=AWL=-1.074, BAYES_40=-0.185, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, HTML_50_60=0.134, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200704/63 X-Sequence-Number: 25127 --_bb7ede35-5096-490b-96b5-fa0e9534ea97_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi, =20 I am using 8.1.0 postgres and trying to write a plpgsql block. In that = I am inserting a row. I want to check to see if the row has been inserted = or not. =20 In oracle we can say like this =20 begin insert into table_a values (1); if sql%rowcount > 0 then dbms.output.put_line('rows inserted'); else=20 dbms.output.put_line('rows not inserted'); end if; end; =20 Is there something equal to sql%rowcount in postgres? Please help. =20 Regards skarthi =20 _________________________________________________________________ It=92s tax season, make sure to follow these few simple tips=20 http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.= aspx?icid=3DWLMartagline= --_bb7ede35-5096-490b-96b5-fa0e9534ea97_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi,
 
   I am using 8.1.0 postgres and trying to write a plpgsql block.=   In that I am inserting a row.  I want to check to see if the ro= w has been inserted or not.
 
  In oracle we can say like this
 
   begin
     insert into table_a values (1);
     if sql%rowcount > 0
     then
       dbms.output.put_line('rows inserted');=
     else
       dbms.output.put_line('rows not inserte= d');
    end if;
end;
 
Is there something equal to sql%rowcount in postgres?   Please he= lp.
 
Regards
skarthi
 


It=92s tax season, make sure to follow these few simp= le tips Check it out!= = --_bb7ede35-5096-490b-96b5-fa0e9534ea97_-- From mike@fuhr.org Sat Apr 7 17:51:10 2007 Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 9035C9FB59E for ; Sat, 7 Apr 2007 14:51:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 92416-10 for ; Sat, 7 Apr 2007 14:50:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id C35CF9FB295 for ; Sat, 7 Apr 2007 14:51:06 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id l37Hp1sm011977 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 7 Apr 2007 11:51:04 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id l37Hp1ls080092; Sat, 7 Apr 2007 11:51:01 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id l37Hp0IS080091; Sat, 7 Apr 2007 11:51:00 -0600 (MDT) (envelope-from mfuhr) Date: Sat, 7 Apr 2007 11:51:00 -0600 From: Michael Fuhr To: Karthikeyan Sundaram Cc: postgres sql Subject: Re: rowcount function in postgres??? Message-ID: <20070407175100.GA80042@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/90 X-Sequence-Number: 28090 On Sat, Apr 07, 2007 at 10:33:19AM -0700, Karthikeyan Sundaram wrote: > I am using 8.1.0 postgres and trying to write a plpgsql block. 8.1.8 is the latest version in that branch. Read the Release Notes for each minor release to see what bug fixes you're missing. http://www.postgresql.org/docs/8.1/interactive/release.html > In that I am inserting a row. I want to check to see if the row > has been inserted or not. See "Obtaining the Result Status" and "Trapping Errors" in the PL/pgSQL documentation. 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 From rdeleonp@gmail.com Sat Apr 7 17:54:40 2007 Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 87CB39FB5DF for ; Sat, 7 Apr 2007 14:54:40 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 28981-07 for ; Sat, 7 Apr 2007 14:54:35 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.240]) by postgresql.org (Postfix) with ESMTP id B5ECA9FB4E5 for ; Sat, 7 Apr 2007 14:54:36 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id c24so1292790ana for ; Sat, 07 Apr 2007 10:54:35 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=kEJOh+J3VdFxwTxdeGwpcIUyP0RAtWDj5jJQYKfIU/gHOVgoFzAZnKng5kwojtPZAnWi0iUyH6lQz6YVREvsvO3f79/7dhMjyd5yoyemXbdV/z3pp/fZGSpskvHDjAfFRAWqh7KCaKaQeJW3Jn/qmpi94CNWVsC2Jm/hY7PiDk0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CW++XZYFl/YhPt/yLF3AuQXk2fuovM4p0WcQL6P8fNbMjU5CEvx8Gb/CL31jhkltkATXbA+W+mx8VkcymY4/8KADxmbcKattku7gi2r9gnz8WED68MLfBP64vReckma/f/ylpaZS7j0vVsgH/1KTTUYPvAEFYnT3bB5hx/X42E0= Received: by 10.100.96.2 with SMTP id t2mr2942742anb.1175968475493; Sat, 07 Apr 2007 10:54:35 -0700 (PDT) Received: by 10.100.177.2 with HTTP; Sat, 7 Apr 2007 10:54:35 -0700 (PDT) Message-ID: Date: Sat, 7 Apr 2007 12:54:35 -0500 From: "=?ISO-8859-1?Q?Rodrigo_De_Le=F3n?=" To: pgsql-admin@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] rowcount function in postgres??? Cc: "Karthikeyan Sundaram" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/65 X-Sequence-Number: 25129 On 4/7/07, Karthikeyan Sundaram wrote: > > Hi, > > I am using 8.1.0 postgres and trying to write a plpgsql block. In that > I am inserting a row. I want to check to see if the row has been inserted > or not. > > In oracle we can say like this > > begin > insert into table_a values (1); > if sql%rowcount > 0 > then > dbms.output.put_line('rows inserted'); > else > dbms.output.put_line('rows not inserted'); > end if; > end; > > Is there something equal to sql%rowcount in postgres? Please help. > > Regards > skarthi Maybe: http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-ONEROW From uwe@oss4u.com Sat Apr 7 18:58:32 2007 Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 69C069FB4D3 for ; Sat, 7 Apr 2007 15:58:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 74766-05 for ; Sat, 7 Apr 2007 15:58:29 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from oss4u.com (mail.oss4u.com [64.142.76.151]) by postgresql.org (Postfix) with SMTP id 0E52D9FB322 for ; Sat, 7 Apr 2007 15:58:28 -0300 (ADT) Received: (qmail 19236 invoked by uid 453); 7 Apr 2007 18:58:27 -0000 Received: from ibserver.oss4u.com (HELO tiburon.oss4u.com) (192.168.1.4) by oss4u.com (qpsmtpd/0.32) with ESMTP; Sat, 07 Apr 2007 11:58:27 -0700 From: "Uwe C. Schroeder" To: pgsql-admin@postgresql.org Subject: Re: rowcount function in postgres??? Date: Sat, 7 Apr 2007 11:58:24 -0700 User-Agent: KMail/1.8.2 Cc: Karthikeyan Sundaram , postgres sql References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-Id: <200704071158.24293.uwe@oss4u.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/66 X-Sequence-Number: 25130 you could simply write insert into table_a values (1); if found then dbms.output.put_line('rows inserted'); else dbms.output.put_line('rows not inserted'); end if; If you really need the number of records inserted (found will be true if at least one record as affected), you can get that with GET DIAGNOSTICS num_rows = ROW_COUNT; and then do the if on the variable num_rows. Hope that helps UC On Saturday 07 April 2007 10:33, Karthikeyan Sundaram wrote: > Hi, > > I am using 8.1.0 postgres and trying to write a plpgsql block. In that > I am inserting a row. I want to check to see if the row has been inserted > or not. > > In oracle we can say like this > > begin > insert into table_a values (1); > if sql%rowcount > 0 > then > dbms.output.put_line('rows inserted'); > else > dbms.output.put_line('rows not inserted'); > end if; > end; > > Is there something equal to sql%rowcount in postgres? Please help. > > Regards > skarthi > > _________________________________________________________________ > It’s tax season, make sure to follow these few simple tips > http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips. >aspx?icid=WLMartagline -- UC -- Open Source Solutions 4U, LLC 1618 Kelly St Phone: +1 707 568 3056 Santa Rosa, CA 95401 Cell: +1 650 302 2405 United States Fax: +1 707 568 6416