X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id D06BC9F9C18 for ; Thu, 18 May 2006 14:54:06 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 48555-06 for ; Thu, 18 May 2006 14:54:00 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.189]) by postgresql.org (Postfix) with ESMTP id 5C20E9F9316 for ; Thu, 18 May 2006 14:54:00 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id y38so168923nfb for ; Thu, 18 May 2006 10:53:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=lKFKVAObOUbXSkgEpCtqZZme/sBvF13tdZTXxS/cDd3LffPcMPQEfR9hCTXIq3XpmXUKQXkiM4Mw75j/2bjjADpgmeeO1O0rNo7SvSgUDoGIvoZBqw+a7Tn5B0bA5z1Ea2TzXPOiemdqC+AOhjfnLDXobR5C6FDjpaLbJKFBJHc= Received: by 10.49.39.1 with SMTP id r1mr765566nfj; Thu, 18 May 2006 10:53:58 -0700 (PDT) Received: by 10.48.226.3 with HTTP; Thu, 18 May 2006 10:53:58 -0700 (PDT) Message-ID: <6d8daee30605181053g29ffbeccy2f4e13b9aedccaf5@mail.gmail.com> Date: Thu, 18 May 2006 10:53:58 -0700 From: "Tony Wasson" To: "Michael Joseph Tan" Subject: Re: help..postgresql mulyiple return values Cc: pgsql-sql@postgresql.org In-Reply-To: <20060512103804.82877.qmail@web50105.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20060512103804.82877.qmail@web50105.mail.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/148 X-Sequence-Number: 25179 On 5/12/06, Michael Joseph Tan wrote: > > hi, > im new in postgresql, generally new in databases. > > im trying to make a function using PGAdminIII which returns several types= , > example, my query is: > > "select count(id) as requests, organization from connection_requests grou= p > by organization" > > id is of type int8, organization is of type varchar(50). > > basically the query would return coun(id), and a varchar(50) which is > organization. > > i really dont know what to put on the return type. > > what would be the best solution? If you are in 8.1 you can follow this example from the documentation. http://www.postgresql.org/docs/8.1/interactive/plpgsql-declarations.html CREATE FUNCTION sum_n_product(x int, y int, OUT sum int, OUT prod int) AS $= $ BEGIN sum :=3D x + y; prod :=3D x * y; END; $$ LANGUAGE plpgsql; Then run it like: SELECT sum, prod FROM sum_n_product(1,2);