The Open Source Swiss Army Knife

/sql_servers/postgresql/pg_plpgsql/
/sql_servers/postgresql/pg_plpgsql/ + sub-categories
http://www.sirfsup.com/
web directory content
    
      

Not logged in
Chat Register Login
return to:  http:/www.sirfsup.com      /sql_servers   /postgresql   /pg_plpgsql 
Permalink: setreturningFunctions.sql
Title: loops without cursor prints out results from select from function
article options : please login   |  raw source view  

create function SqlDepartmentSalaries() returns setof holder as
'

select departmentid, sum(salary) as totalsalary from GetEmployees() group by departmentid
'
language 'sql';

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
'
language 'plpgsql';


Leave a Reply
Your Name:     anonymous
Your Email:
Website:  
Comments:

The author will be notified of your reply.
return to top