Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 704C69FB998 for ; Wed, 25 Apr 2007 10:54:38 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 93083-06 for ; Wed, 25 Apr 2007 10:54:32 -0300 (ADT) X-Greylist: delayed 17:12:27.557558 by SQLgrey-1.7.4 Received: from insiderscore.com (mail01.insiderscore.com [69.84.139.233]) by postgresql.org (Postfix) with ESMTP id 266929FB90D for ; Wed, 25 Apr 2007 10:54:32 -0300 (ADT) Received: from [192.168.1.111] (mail01.insiderscore.com [69.84.139.233]) by insiderscore.com (Postfix) with ESMTP id 597C69B07FC; Wed, 25 Apr 2007 09:54:30 -0400 (EDT) Subject: Re: plpgsql array looping From: Richard Albright To: John DeSoi Cc: pgsql-sql@postgresql.org In-Reply-To: <965E504A-7301-4531-B381-A1EEEB539344@pgedit.com> References: <1177447321.17092.9.camel@MSI1036> <965E504A-7301-4531-B381-A1EEEB539344@pgedit.com> Content-Type: text/plain Date: Wed, 25 Apr 2007 09:54:29 -0400 Message-Id: <1177509269.9556.2.camel@MSI1036> Mime-Version: 1.0 X-Mailer: Evolution 2.10.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/244 X-Sequence-Number: 28244 yeah i noticed that this morning, it used to be a while loop, for some reason (probably parser related) it keeps giving me an error on the exit when statement in the loop. On Wed, 2007-04-25 at 09:38 -0400, John DeSoi wrote: > One problem (unless you intend to only look at every other element) > is that you are incrementing idxptr explicitly in your loop. The FOR > loop does that for you. This is the reason your output shows only > even values. > > John > > > On Apr 24, 2007, at 4:42 PM, Richard Albright wrote: > > > for idxptr in 1 .. array_upper(p_idxarray, 1) > > loop > > exit when p_idxarray[idxptr] >= p_idx; > > idxptr := idxptr +1; > > raise notice 'idx ptr: %', idxptr; > > end loop; > > > > John DeSoi, Ph.D. > http://pgedit.com/ > Power Tools for PostgreSQL > > > ---------------------------(end of broadcast)--------------------------- > TIP 7: You can help support the PostgreSQL project by donating at > > http://www.postgresql.org/about/donate -- Rick Albright Senior Quantitative Analyst Indie Research, LLC 254 Witherspoon Street Princeton, NJ 08542 (609)497-1030 ralbright@insiderscore.com