Re: functions

From: Lennin Caro <lennin(dot)caro(at)yahoo(dot)com>
To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>, C K <shreeseva(dot)it(at)gmail(dot)com>
Subject: Re: functions
Date: 2008-08-04 13:33:25
Message-ID: 642766.26746.qm@web59508.mail.ac4.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

create a type and return this

--- On Sat, 8/2/08, C K <shreeseva(dot)it(at)gmail(dot)com> wrote:

> From: C K <shreeseva(dot)it(at)gmail(dot)com>
> Subject: [ADMIN] functions
> To: "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org>
> Date: Saturday, August 2, 2008, 9:39 AM
> Dear Friends,
> I have written a function as follows. Here I need to get
> the sum of balance
> before the user provided date. The below function works
> well, but returns
> records as a set of values, rather I need individual
> columns. What to do?
> CREATE OR REPLACE FUNCTION aa(date)
> RETURNS SETOF record AS
> $BODY$SELECT docacctransactions.accgroupid,
> Sum(docacctransactions.credit)
> AS OSC, Sum(docacctransactions.debit) AS OSD
> FROM docs INNER JOIN docacctransactions ON docs.docid =
> docacctransactions.docid
> WHERE docs.includeinbalcalc=-1 AND
> docs.transactiontype<>1 AND
> docs.docdate<=$1
> GROUP BY docacctransactions.accgroupid;
> $BODY$
> LANGUAGE 'sql' VOLATILE
> COST 100
> ROWS 1000;
> ALTER FUNCTION aa(date) OWNER TO sa;
>
> I am using WinXP SP 2 with PostgreSQL 8.3 with ODBC
> Please help.
> CPK
> --
> Keep your Environment clean and green.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Kesavan 2008-08-04 15:49:11 Maximum number of concurrent users
Previous Message Andrew Goodnough 2008-08-04 04:25:24 Re: client_encoding error on load