From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Nikiforuk <Kevin.Nikiforuk@Acrodex.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Error when trying to use a FOR loop
Date: Fri, 21 Jul 2006 11:40:11 -0400
Message-ID: <29387.1153496411@sss.pgh.pa.us> (raw)
In-Reply-To: <6EA72AC41F81D242A38AAF505523A94D022DF4@kappa.acrodex.net>
References: <6EA72AC41F81D242A38AAF505523A94D022DF4@kappa.acrodex.net>
"Kevin Nikiforuk" <Kevin.Nikiforuk@Acrodex.com> writes:
> CREATE OR REPLACE FUNCTION rgio() RETURNS integer as $$
> BEGIN
> DECLARE lv RECORD;
> FOR lv IN SELECT DISTINCT rg FROM ldevrg LOOP
> SELECT ldev FROM ldevrg WHERE ldevrg='$lv';
> END LOOP;
> RETURN 1;
> END;
> $$ LANGUAGE plpgsql;
You've got a small error in the layout: the DECLARE part goes before
BEGIN not after. Swap the first two lines of the function.
regards, tom lane
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: tgl@sss.pgh.pa.us, Kevin.Nikiforuk@Acrodex.com
Subject: Re: Error when trying to use a FOR loop
In-Reply-To: <29387.1153496411@sss.pgh.pa.us>
* 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