Re: Plpgsql: Iterating through a string of parameters

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Plpgsql: Iterating through a string of parameters
Date: 2010-03-26 08:49:02
Message-ID: hohsdu$52m$2@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 2010-03-25, Leif Biberg Kristensen <leif(at)solumslekt(dot)org> wrote:
> I'm struggling with how to make plpgsql iterate through a list of numbers
> input as a text string, eg. "1438 2656 973 4208". I figure that I can use the
> regexp_split_to_array() function to make an array of the string, but can I
> iterate through an array with eg. a FOR loop?

using regex_split_to_table with for is easier

for x in regex_split_to_table(....) do

But if you must you can use split to array and then use the array measuring
functions to determine the limit for a counted for loop.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ireneusz Pluta 2010-03-26 10:48:39 Re: Week to date function
Previous Message Thomas Kellerer 2010-03-26 07:14:50 Re: SQL syntax rowcount value as an extra column in the result set