Consulta sobre Set Returning Functions con Record

From: Raul Caso <feve18(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Consulta sobre Set Returning Functions con Record
Date: 2005-11-29 21:34:24
Message-ID: 4dda42060511291334n57dd6579x@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Hola amigos esta es mi consulta cuando realizaba una funcion asi me
devolvia los resultados en filas y columnas todo bien hasta ahi normal
create or replace function PLpgSQLDepartmentSalaries() returns setof holder
as

'
declare
r holder%rowtype;
begin
for r in select departmentid, sum(salary) as totalsalary from
GetEmployees() group by departmentid loop
return next r;
end loop;
return;
end

pero cuando en vez de devolver una tabla intentaba devolver un record
por que no queria que me devolviera todos los
datos de la tabla algo asi:
create or replace function GetRows(text) returns setof record as
'
declare
r record;
begin
for r in EXECUTE ''select id,name,costo from '' || $1 loop
return next r;
end loop;
return;
end

al momento de llamarlo me daba un error de que no habia pasado una
lista de columnas para el record asi k encontre algo de llamarlo asi
select * from GetRows('Department') as dept(deptid int, deptname
text); y funciona mi dudas es que siempre que quiera llamarlo tengo
que
agregar "as dept(deptid int, deptname text)" hay una forma de simplificar eso?

--
Raulinho
97033825-4327239

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jim C. Nasby 2005-11-29 21:39:04 Re: Delete slow...
Previous Message Jaime Casanova 2005-11-29 21:33:17 Re: [ADMIN] Fatal : IDENT authentication