problems with pgplsql looping through query results (FOR row IN)

From: Feite Brekeveld <feite(dot)brekeveld(at)osiris-it(dot)nl>
To: pgsql-general(at)postgresql(dot)org
Subject: problems with pgplsql looping through query results (FOR row IN)
Date: 2001-04-04 15:19:00
Message-ID: 3ACB3B64.AC2ABAF@osiris-it.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Hi,

Trying to get grip on FOR row IN select clause using this
testfunction.

The FOR row|record in is the one I can't get to work.

CREATE FUNCTION dosomething (varchar)
RETURNS integer
AS '
DECLARE
_conn_id ALIAS FOR $1;
ts integer;
cdrrec record;
BEGIN
ts := 0;
FOR row IN
SELECT *
FROM cdr_accounting
WHERE connection_id = _conn_id
LOOP
ts := ts + row.time_stamp
END LOOP;

return ts;
END;'
LANGUAGE 'plpgsql';

How to get this one to work ?

Thanks,

--
Feite Brekeveld
feite(dot)brekeveld(at)osiris-it(dot)nl
http://www.osiris-it.nl

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martín Marqués 2001-04-04 15:52:03 Re: Re: php Compile question
Previous Message Tom Lane 2001-04-04 15:17:40 Re: problems with pgplsql looping through query results (FOR row IN)