What is made a mistake with SP? - Mailing list pgsql-general

From Marcos
Subject What is made a mistake with SP?
Date
Msg-id 1138004834.949.19.camel@servidor
Whole thread Raw
Responses Re: What is made a mistake with SP?  (John DeSoi <desoi@pgedit.com>)
List pgsql-general
Hi,

I need create SP that returns cursos so that I can work with them.

I have many SQLs used for search records in database, then I will make
SP to return the results.

The example that I'm trying is:

CREATE OR REPLACE FUNCTION fun_compras_calculado() RETURNS SETOF
tipo_compras_calculado AS '
DECLARE
   linha_compras    RECORD;
   linha_calculada  tipo_compras_calculado;
BEGIN
   linha_calculada.acumulado := 0;
   FOR linha_compras IN
     SELECT id, qtd, produto, unitario FROM compras ORDER BY id
   LOOP
     linha_calculada.id := linha_compras.id;
     linha_calculada.produto := linha_compras.produto;
     linha_calculada.qtd := linha_compras.qtd;
     linha_calculada.unitario := linha_compras.unitario;
     linha_calculada.valor := linha_compras.qtd * linha_compras.unitario;
     linha_calculada.acumulado := linha_calculada.acumulado + linha_calculada.valor;
     RETURN NEXT linha_calculada;
   END LOOP;
   RETURN;
END;
' LANGUAGE 'plpgsql';


pgsql-general by date:

Previous
From: "surabhi.ahuja"
Date:
Subject: Re: logging connections
Next
From: Achilleus Mantzios
Date:
Subject: DBMirror.pl performance change