pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John DeSoi <desoi@pgedit.com>
To: Richard Albright <ralbright@insiderscore.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: plpgsql array looping
Date: Wed, 25 Apr 2007 09:38:09 -0400
Message-ID: <965E504A-7301-4531-B381-A1EEEB539344@pgedit.com> (raw)
In-Reply-To: <1177447321.17092.9.camel@MSI1036>
References: <1177447321.17092.9.camel@MSI1036>

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




view thread (3+ messages)  latest in thread

Message-ID: <965E504A-7301-4531-B381-A1EEEB539344@pgedit.com>
Permalink:  ../965E504A-7301-4531-B381-A1EEEB539344@pgedit.com/
Also on:    postgresql.org/message-id/965E504A-7301-4531-B381-A1EEEB539344@pgedit.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: desoi@pgedit.com, ralbright@insiderscore.com
  Subject: Re: plpgsql array looping
  In-Reply-To: <965E504A-7301-4531-B381-A1EEEB539344@pgedit.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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