Those instructions are good but i want to call this function only for " select consulta_contacto(1)" nothing more, Is really necesary to use "AS ..."?
this is the call:
select * from consulta_contacto(1) as (cont_codigo integer,
cont_idpers varchar,
cont_nombre varchar,
cont_apellido varchar,
cont_titulo varchar,
cont_fecnac timestamp ,
cont_codedociv integer,
cont_sexo char(1),
cont_codpais integer,
cont_pw varchar,
cont_empr varchar,
cont_cargo varchar,
cont_pwempr varchar,
cont_aniv char(5),
cont_prof varchar,
cont_trab char(1),
cont_fecgen timestamp,
cont_fecing timestamp,
cont_fuente char(1),
cont_sinc char(1),
cont_codupload integer);
this is the function:
CREATE OR REPLACE FUNCTION consulta_contacto(integer) RETURNS SETOF RECORD AS '
DECLARE
rec RECORD;
sup INTEGER;
BEGIN
FOR rec IN SELECT cont_codigo,cont_idpers, cont_nombre,cont_apellido,cont_titulo,cont_fecnac,cont_codedociv,cont_sexo,cont_codpais,cont_pw,cont_empr,cont_cargo,cont_pwempr,cont_aniv,cont_prof,cont_trab,cont_fecgen,cont_fecing,cont_fuente,cont_sinc,cont_codupload
FROM tbu_contacto
LOOP
RETURN NEXT rec ;
END LOOP;
RETURN ;
END;
' LANGUAGE plpgsql;