Re: returns de las funciones

From: "Ing(dot) Jhon Carrillo - Caracas, Venezuela" <jdigital(at)cantv(dot)net>
To: "Raisa Perdomo Miranda" <raisaperdomo(at)gmail(dot)com>, <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: returns de las funciones
Date: 2005-05-27 13:42:27
Message-ID: 04f901c562c1$ec632d60$1400a8c0@tgusta2
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola, espero te sirva

CREATE OR REPLACE FUNCTION alguna_funcion()
RETURNS SETOF tu_tabla AS
'
DECLARE
rec tu_tabla;
BEGIN
FOR rec IN select * from tu_tabla LOOP
RETURN NEXT rec;
END LOOP;
RETURN;
END'
LANGUAGE 'plpgsql' ;

Jhon Carrillo
Ingeniero en Computación
jdigital+(at)+cantv+(dot)+net (quitar +)
+584145246033
Caracas - Venezuela

----- Original Message -----
From: Raisa Perdomo Miranda
To: pgsql-es-ayuda(at)postgresql(dot)org
Sent: Thursday, May 26, 2005 6:54 PM
Subject: [pgsql-es-ayuda] returns de las funciones

hola lista...
cuado quiero que la funcion me devuelva una consulta de que tipo de dato debe ser RETURNS?, un record, no?
pero en el cuerpo de la funcion que debo devolver en RETURN?

por ejemplo:

CREATE OR REPLACE FUNCTION "public"."prueba" (id_persona VARCHAR) RETURNS "pg_catalog"."record" AS
$body$
begin
select * from tbl_persona where id_persona = '01';
return record; --DUDA
end
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

de esta manera me da el siguiente error:
ERROR: RETURN must specify a record or row variable in function returning tuple at or near "record" at character 167

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jairo Martín Miguel 2005-05-27 13:55:21 Re: returns de las funciones
Previous Message Ricardo Fuentes Pereira 2005-05-27 13:39:53 Consulta compleja