From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Ari Kahn <akahn1@gmu.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: plpgsql and for with integer loopvar error
Date: Mon, 17 Jan 2005 11:38:55 -0800 (PST)
Message-ID: <20050117113239.I13804@megazone.bigpanda.com> (raw)
In-Reply-To: <BDCD90E6-6770-11D9-97FB-000D936D7BC4@gmu.edu>
References: <BDCD90E6-6770-11D9-97FB-000D936D7BC4@gmu.edu>
On Sat, 15 Jan 2005, Ari Kahn wrote:
> CREATE FUNCTION gets_nooky() returns numeric AS
> '
> DECLARE
> i integer;
> gt1cnt record;
> gt1 record;
> cluster record;
> cluster_cnt integer;
> slocus integer;
> minmax record;
>
> BEGIN
> SELECT INTO gt1 * FROM cgt1;
> SELECT count(*) INTO gt1cnt FROM cgt1;
>
> FOR i IN 1 .. SELECT count(*) FROM cgt1
I think either of
(SELECT count(*) FROM cgt1)
or
count(*) from cgt1
should work in practice (I personally like the former because that's the
scalar subquery syntax), however, since you're getting the count into
gt1cnt, why not just use the variable?
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: sszabo@megazone.bigpanda.com, akahn1@gmu.edu
Subject: Re: plpgsql and for with integer loopvar error
In-Reply-To: <20050117113239.I13804@megazone.bigpanda.com>
* 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