pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kumar <sgnerd@yahoo.com.sg>
To: psql <pgsql-sql@postgresql.org>
Subject: Return more than a record
Date: Thu, 26 Feb 2004 19:21:37 +0530
Message-ID: <036901c3fc6f$a9159840$7502a8c0@hdsc.com> (raw)

Dear Friends,

Postgres 7.3.4 on RH Linux 7.2.

Get the following from the groups
create or replace function ExpensiveDepartments() returns setof table1 as 
'
declare
    r table1%rowtype;
begin
    for r in select departmentid, sum(salary) as totalsalary
        from GetEmployees() group by departmentid loop

        if (r.totalsalary > 70000) then
            r.totalsalary := CAST(r.totalsalary * 1.75 as int8);
        else
            r.totalsalary := CAST(r.totalsalary * 1.5 as int8);
        end if;

        if (r.totalsalary > 100000) then
            return next r.departmentid;
        end if;

    end loop;
    return;
end
' 
language 'plpgsql';
Is possible for me to return a variable along with that 'return' statement? Because the table 'table1' contains some date
column. I have done some calculation on those columns and want to return the calculated  date along with that row of the
table1. How to do that. Please shed some light.

view thread (4+ messages)  latest in thread

Message-ID: <036901c3fc6f$a9159840$7502a8c0@hdsc.com>
Permalink:  ../036901c3fc6f$a9159840$7502a8c0@hdsc.com/
Also on:    postgresql.org/message-id/036901c3fc6f$a9159840$7502a8c0@hdsc.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sgnerd@yahoo.com.sg
  Subject: Re: Return more than a record
  In-Reply-To: <036901c3fc6f$a9159840$7502a8c0@hdsc.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox