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

Поиск
Список
Период
Сортировка
От Feite Brekeveld
Тема problems with pgplsql looping through query results (FOR row IN)
Дата
Msg-id 3ACB3B64.AC2ABAF@osiris-it.nl
обсуждение исходный текст
Ответы Re: problems with pgplsql looping through query results (FOR row IN)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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.brekeveld@osiris-it.nl
http://www.osiris-it.nl




В списке pgsql-general по дате отправления:

Предыдущее
От: "Oliver Elphick"
Дата:
Сообщение: Re: Re: unrecognized language plpgsql
Следующее
От: "Gregory Wood"
Дата:
Сообщение: Re: problems with variabiles in plpgsql