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