[Pgsql-ayuda] funcion y setof record

Leonardo Boet Sánchez boet@gtm.tel.etecsa.cu
Tue, 3 Jun 2003 12:21:35 -0400


Tengo 2 tablas que relaciono y necesito devolver campos y una parte de un campo, la función es la siguiente :

CREATE FUNCTION cumplemes(bpchar) RETURNS  SETOF record AS 
'select select trab.nombre, unidad.descrip, substring(trab.cident from 5 for 2) as dia1
from trab inner join unidad on trab.unidad = unidad.unid 
where substring(trab.cident from 3 for 2)= $1  
order by trab.nombre asc' LANGUAGE 'sql' VOLATILE;

al ejecutarla
select * from cumplemes('07') as temp(nombre varchar, descrip varchar, dia1 varchar);

me da el siguiente error: ERROR:  Query-specified return tuple and actual function return tuple do not match.

¿¿Qué debo hacer si no quiero definir un tipo??

Boet