Re: plpgsql and for with integer loopvar error - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: plpgsql and for with integer loopvar error
Date
Msg-id 20050117113239.I13804@megazone.bigpanda.com
Whole thread Raw
In response to plpgsql and for with integer loopvar error  (Ari Kahn <akahn1@gmu.edu>)
List pgsql-sql
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)
orcount(*) 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?


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: query configuration for validate empty quote to zero
Next
From: "Yudie"
Date:
Subject: Re: query configuration for validate empty quote to zero