X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3D8F53A3D26 for ; Wed, 19 Jan 2005 06:39:33 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33772-10 for ; Wed, 19 Jan 2005 06:39:28 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id C61AA3A3D0C for ; Wed, 19 Jan 2005 06:39:28 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id j0J6dNGc004621 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 18 Jan 2005 23:39:26 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id j0J6dN7a057206; Tue, 18 Jan 2005 23:39:23 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id j0J6dJ5C057205; Tue, 18 Jan 2005 23:39:19 -0700 (MST) (envelope-from mfuhr) Date: Tue, 18 Jan 2005 23:39:19 -0700 From: Michael Fuhr To: Bradley Miller Cc: pgsql-sql@postgresql.org Subject: Re: URGENT: Using function inside query Message-ID: <20050119063918.GA57167@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/138 X-Sequence-Number: 19926 On Tue, Jan 18, 2005 at 02:51:01PM -0600, Bradley Miller wrote: > select account_id from roll_account(1186) where hierarchy_type_id = 2 > > The problem is I have data like this: > > account id name > > 1 Company A > 2 Company B > 3 Company C > 4 Person 1 (in Company A) > 5 Person 2 (in Company A) > > If I pass it the number of let's say Person 2 -- the above query wold > give me the account id of 1. How can I do a query using that > function so that it automatically inserts the account_id to show the > "rolled up" account id ? I'm not sure I follow -- what account_id are you trying to insert and where are you trying to insert it? Do you want something like this? SELECT account_id FROM roll_account( (SELECT account_id FROM account_info WHERE name = 'Person 2') ) WHERE hierarchy_type_id = 2; If that's not what you're after then please provide an example of the kind of query you'd like to make and what results you expect. -- Michael Fuhr http://www.fuhr.org/~mfuhr/