X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 90BFCD1DF4D for ; Thu, 26 Feb 2004 13:51:16 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 22899-07 for ; Thu, 26 Feb 2004 09:51:15 -0400 (AST) Received: from smtp014.mail.yahoo.com (smtp014.mail.yahoo.com [216.136.173.58]) by svr1.postgresql.org (Postfix) with SMTP id 69528D1DD5F for ; Thu, 26 Feb 2004 09:51:10 -0400 (AST) Received: from unknown (HELO IVESIA67) (sgnerd@203.196.190.138 with login) by smtp014.mail.yahoo.com with SMTP; 26 Feb 2004 13:51:11 -0000 Message-ID: <036901c3fc6f$a9159840$7502a8c0@hdsc.com> Reply-To: "Kumar" From: "Kumar" To: "psql" Subject: Return more than a record Date: Thu, 26 Feb 2004 19:21:37 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0366_01C3FC9D.C11BDE80" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/362 X-Sequence-Number: 17052 This is a multi-part message in MIME format. ------=_NextPart_000_0366_01C3FC9D.C11BDE80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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= =20 ' 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 :=3D CAST(r.totalsalary * 1.75 as int8); else r.totalsalary :=3D CAST(r.totalsalary * 1.5 as int8); end if; if (r.totalsalary > 100000) then return next r.departmentid; end if; end loop; return; end '=20 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 th= e calculated date along with that row of the table1. How to do that. Please shed some light. ------=_NextPart_000_0366_01C3FC9D.C11BDE80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dear Friends,
 
Postgres 7.3.4 on RH Linux 7.2.
 
Get the following from the groups
create or replace function ExpensiveDepartments() returns setof ta=
ble1 as=20
'
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 :=3D CAST(r.totalsalary * 1.75 as int8);
        else
            r.totalsalary :=3D CAST(r.totalsalary * 1.5 as int8);
        end if;

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

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

------=_NextPart_000_0366_01C3FC9D.C11BDE80--