Re: [GENERAL] looping over a small record set over and over in a function

2009-06-20 Thread Craig Ringer
On Fri, 2009-06-19 at 20:23 +0200, Ivan Sergio Borgonovo wrote: > If I could easily load all the dataset into an array, loop through > it and then just update the computed field it would be nice... but > how? Are you sure you _really_ need a PL/PgSQL function for this? Can't you: SELECT x.*, co

Re: [GENERAL] looping over a small record set over and over in a function

2009-06-20 Thread John DeSoi
On Jun 20, 2009, at 8:35 AM, Ivan Sergio Borgonovo wrote: And lastly, if your current approach really is the only way to compute what you're after, then maybe PL/pgSQL isn't the right match for the problem; it looks like you'd be better served by a Yeah. I gave a look to python but I don't wa

Re: [GENERAL] looping over a small record set over and over in a function

2009-06-20 Thread Ivan Sergio Borgonovo
On Sat, 20 Jun 2009 12:30:42 +0200 Alban Hertroys wrote: > You could add a column to your query as a placeholder for the > computed value. > For example, SELECT *, 0 AS computed_value FROM table. > If you use a scrollable cursor (possible in PL/pgSQL these days, > although it still has some li

Re: [GENERAL] looping over a small record set over and over in a function

2009-06-20 Thread Alban Hertroys
On Jun 19, 2009, at 8:23 PM, Ivan Sergio Borgonovo wrote: I've a record set on which I have to loop several times. The function should return the same record set + one more computed field. Something that in could look like: foreach(row) { // compute stuff if(...) { } // place stuff in field[

[GENERAL] looping over a small record set over and over in a function

2009-06-19 Thread Ivan Sergio Borgonovo
I've a record set on which I have to loop several times. The function should return the same record set + one more computed field. Something that in could look like: foreach(row) { // compute stuff if(...) { } // place stuff in field[N+1] of the row } if(some condition) { // } foreach(r