Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 982F9650060 for ; Mon, 4 Aug 2008 10:33:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 53533-03 for ; Mon, 4 Aug 2008 10:33:22 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from n3a.bullet.mail.ac4.yahoo.com (n3a.bullet.mail.ac4.yahoo.com [76.13.13.66]) by postgresql.org (Postfix) with SMTP id 86C3864FD2F for ; Mon, 4 Aug 2008 10:33:27 -0300 (ADT) Received: from [76.13.13.25] by n3.bullet.mail.ac4.yahoo.com with NNFMP; 04 Aug 2008 13:33:25 -0000 Received: from [76.13.10.182] by t4.bullet.mail.ac4.yahoo.com with NNFMP; 04 Aug 2008 13:33:25 -0000 Received: from [127.0.0.1] by omp123.mail.ac4.yahoo.com with NNFMP; 04 Aug 2008 13:33:25 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 883163.12211.bm@omp123.mail.ac4.yahoo.com Received: (qmail 27356 invoked by uid 60001); 4 Aug 2008 13:33:25 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=F2aRU+Fe3rf8ppb9vNO0iJha361CCB3HVvu90HonoJ6ye7G38DoiEtk6M8bvP+O4m+DLVnBn/rGQUKZcFkhwMPttRYT6SPDaiV9/9ZUCEhAh1dwOYIf1Y9Kvo8E9P6Iw65MSdFuGDRCfJCAIJoWfBglWK+SgxoI732K/g5wxs/k=; Received: from [209.88.228.11] by web59508.mail.ac4.yahoo.com via HTTP; Mon, 04 Aug 2008 06:33:25 PDT X-Mailer: YahooMailWebService/0.7.218 Date: Mon, 4 Aug 2008 06:33:25 -0700 (PDT) From: Lennin Caro Reply-To: lennin.caro@yahoo.com Subject: Re: functions To: "pgsql-admin@postgresql.org" , C K In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <642766.26746.qm@web59508.mail.ac4.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.188 tagged_above=0 required=5 tests=RCVD_IN_BL_SPAMCOP_NET=2.188 X-Spam-Level: ** X-Archive-Number: 200808/13 X-Sequence-Number: 29858 create a type and return this --- On Sat, 8/2/08, C K wrote: > From: C K > Subject: [ADMIN] functions > To: "pgsql-admin@postgresql.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.