Skip site navigation (1) Skip section navigation (2)

How to run loop in psql?

From: A B <gentosaker(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: How to run loop in psql?
Date: 2010-06-15 11:44:24
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Hello there.

Perhaps I'm supposed to know this, but how can I run a function on
each query result in psql?

I run the query  select a,b from foo where x=y; and I would like to
run the function bar(u,v) for each result from the query and using
the values of a and b as parameters to the function.
How can I do that in psql?

Something like:

for x in select a,b from foo where x=y loop
    select bar(x.a,x.b);
end loop;

would be great!


pgsql-novice by date

Next:From: A. KretschmerDate: 2010-06-15 11:51:33
Subject: Re: How to run loop in psql?
Previous:From: Jasen BettsDate: 2010-06-15 09:14:57
Subject: Re: (not so?) silly question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group