From josephtan2k@yahoo.com Fri May 12 10:38:13 2006 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 C50399F9C18 for ; Fri, 12 May 2006 07:38:13 -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 16253-02 for ; Fri, 12 May 2006 07:38:05 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web50105.mail.yahoo.com (web50105.mail.yahoo.com [206.190.38.33]) by postgresql.org (Postfix) with SMTP id ABBF59F9430 for ; Fri, 12 May 2006 07:38:05 -0300 (ADT) Received: (qmail 82879 invoked by uid 60001); 12 May 2006 10:38:04 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=EZbvS53kYmHVjJlYzHAFJE9rNFhDWRJWNpURfrUV5wyziiJJRE7olVYTkwWNjrXhiAYhGw4PuVHs2HXGrfRviy4rOaW52yDnZ/kBIhO0RapVDaaKb/33hKOOrPK44W4T70EftwY4EbaWPdZ7nU9ev3Y5PF61AGrqcAOSdfMMMjw= ; Message-ID: <20060512103804.82877.qmail@web50105.mail.yahoo.com> Received: from [202.164.181.114] by web50105.mail.yahoo.com via HTTP; Fri, 12 May 2006 03:38:04 PDT Date: Fri, 12 May 2006 03:38:04 -0700 (PDT) From: Michael Joseph Tan Subject: help..postgresql mulyiple return values To: pgsql-sql@postgresql.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-715679082-1147430284=:81008" Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/123 X-Sequence-Number: 25154 --0-715679082-1147430284=:81008 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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 group 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? hope to hear from you guys asap.. thank you --------------------------------- Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less. --0-715679082-1147430284=:81008 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit
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 group 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?
 
hope to hear from you guys asap..
 
thank you


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less. --0-715679082-1147430284=:81008-- From ajwasson@gmail.com Thu May 18 17:54:06 2006 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);