=D0=92 =D0=9F=D0=BD=D0=B4, 22.11.2004, =D0=B2 00:07, Andr=C3=A9 Toscano =D0=
=BF=D0=B8=D1=88=D0=B5=D1=82:
> Hello, friends.
>
> If anybody can help, how can I do a FUNCTION return a result from a
> SELECT in a table in PostgreSQL?
> My Problem is the RETURN TYPE from a FUNCTION, I don=C2=B4t know what I h=
ave
> to use to return the data as a select result.
>
> Example:
> ----------------
>
> DROP FUNCTION ACADEMICO.teste(int4);
>
> CREATE FUNCTION ACADEMICO.teste(int4)
> RETURNS ?????
> AS
> '
> select cod_aluno, nome, cpf from ACADEMICO.TB_alunos
>
> '
> LANGUAGE 'SQL';
CREATE TYPE foo_type AS (cod_aluno TEXT, nome TEXT, cpf TEXT);
CREATE FUNCTION bar(int4)
RETURNS SETOF foo_type
LANGUAGE 'SQL'
AS '
DECLARE
var_rec foo_type;
BEGIN
FOR var_rec IN SELECT cod_aluno, nome, cpf FROM table WHERE ... LOOP
RETURN NEXT var_rec;
END LOOP;
RETURN;
END;
';
--
Markus Bertheau <twanger [at] bluetwanger.de>
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo [at] postgresql.org so that your
message can get through to the mailing list cleanly
