Estimada Lista
Mi pregunta es sencilla, tengo una función de tipo return set of record con 2 
parámetros de ingreso int y char :
CREATE OR REPLACE FUNCTION "danmaf"."gen_obt_estab_punto_dos" (p_id_empresa 
integer, p_unidad_adm varchar) RETURNS SETOF record AS$body$DECLARE 
v_establecimiento varchar(3); v_punto varchar(3); v_rec_salida record;BEGIN
for v_rec_salida in  (SELECT fa.establecimiento,fa.punto,fa.autorizacion      
FROM  danmaf.gen_documento gd,danmaf.fac_autorizaciones fa      WHERE 
gd.id_documento=fa.id_documento        and gd.nombre='FACTURA'        and 
gd.id_empresa=p_id_empresa        and fa.cod_unidad=p_unidad_adm)   loop  
return next v_rec_salida;                  end loop;       return; 
END;$body$LANGUAGE 'plpgsql'VOLATILECALLED ON NULL INPUTSECURITY INVOKERCOST 
100 ROWS 1000;


Según lo que he leído en la red y una vez que me ayudo Alvaro Herrera, creo que 
estoy haciendo lo correcto:
INTERNET DICE QUE SE EJECUTA ASI:
SELECT "danmaf"."gen_obt_estab_punto_dos"(4,'1') as f(col1 char,col2 char ,col3 
char  );

SELECT "danmaf"."gen_obt_estab_punto_dos"(4,'1') as f(col1 text,col2 text ,col3 
 text );

RESULTADO  ERROR :ERROR:  syntax error at or near "("LINE 1: ...ECT 
"danmaf"."gen_obt_estab_punto_dos"(4,'1') as f(cola text...
ALVARO ME INDICO EN ESTE CORREO:
ALFONSO REYES escribió:

Marcos, muchas gracias por tú ayuda, pero a lo que me refiero es como debería
jecutarla desde el query builder, por ejemplo a las 
funciones que retirnan un refcursor se las ejecuta asi:
Begin;
select funcion('resp_ref_cursor');
fecth all in "resp_ref_cursor";
commit;

En cambio cuando es un afunción de tipo record como la ejecuto desde el query
builder..

select * from function( ... )

Si es "setof record" entonces tienes que especificar el tipo del record:

select * from function( ... ) as f(a int, b text, c text, ...)

-- 
Alvaro Herrera                               http://www.PlanetPostgreSQL.org/
"I'm impressed how quickly you are fixing this obscure issue. I came from 
MS SQL and it would be hard for me to put into words how much of a better job
you all are doing on [PostgreSQL]."
 Steve Midgley, http://archives.postgresql.org/pgsql-sql/2008-08/msg00000.php
--
TIP 3: Si encontraste la respuesta a tu problema, publícala, otros te lo
agradecerán 
Para terminar cuando la ejecuto desde el EXECUTE  de la función del SQL MANAGER 
FOR POSTGRES 2007 SI FUNCIONA !!! Y PRIMERO ME PIDE LAS COLUMNAS y luego 
obtengo el resultado, por favor quisiera saber que estoy haciendo mal...


                                                             ^




_________________________________________________________________
Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.

http://www.microsoft.com/windows/windowslive/products/photos.aspx

Responder a