From: Matthew Schumacher <matt.s@aptalaska.net>
To: pgsql-sql@postgresql.org
Subject: How to loop though an array plpgsql?
Date: Fri, 29 Jul 2005 15:39:12 -0800
Message-ID: <42EABE20.6040805@aptalaska.net> (raw)
I need to loop though an input array, but can't figure out how to do it,
the docs aren't really clear on this.
Something like this:
CREATE FUNCTION update (_id INTEGER[])
RETURNS VOID AS
$$
BEGIN
FOR i IN SELECT _id LOOP
INSERT INTO table VALUES (_id[i]);
END LOOP;
END;
$$
LANGUAGE plpgsql;
Anyone know the correct loop syntax?
schu
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: matt.s@aptalaska.net
Subject: Re: How to loop though an array plpgsql?
In-Reply-To: <42EABE20.6040805@aptalaska.net>
* 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