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 CA6493A259B for ; Tue, 18 Jan 2005 20:50:59 +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 69507-01 for ; Tue, 18 Jan 2005 20:50:48 +0000 (GMT) Received: from lothos.nuvio.com (lothos.ojc.nuvio.com [63.77.68.101]) by svr1.postgresql.org (Postfix) with ESMTP id 4EB3F3A2019 for ; Tue, 18 Jan 2005 20:50:49 +0000 (GMT) Received: from [63.77.68.30] ([63.77.68.30]) by lothos.nuvio.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 18 Jan 2005 14:52:24 -0600 Mime-Version: 1.0 (Apple Message framework v619) To: pgsql-sql@postgresql.org Message-Id: Content-Type: multipart/alternative; boundary=Apple-Mail-24-1072725886 From: Bradley Miller Subject: URGENT: Using function inside query Date: Tue, 18 Jan 2005 14:51:01 -0600 X-Mailer: Apple Mail (2.619) X-OriginalArrivalTime: 18 Jan 2005 20:52:24.0156 (UTC) FILETIME=[9C9081C0:01C4FD9F] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.393 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/136 X-Sequence-Number: 19924 --Apple-Mail-24-1072725886 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed I need some help on the following problem. I have an account info table that has a hierarchy of accounts. The grouping goes from end user to organization to reseller. I have a PL/SQL function written that gives me the tree, so I just whittle it down by selecting the one id for a reseller: 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 ? Bradley Miller NUVIO CORPORATION Phone: 816-444-4422 ext. 6757 Fax: 913-498-1810 http://www.nuvio.com bmiller@nuvio.com --Apple-Mail-24-1072725886 Content-Transfer-Encoding: 7bit Content-Type: text/enriched; charset=US-ASCII I need some help on the following problem. I have an account info table that has a hierarchy of accounts. The grouping goes from end user to organization to reseller. I have a PL/SQL function written that gives me the tree, so I just whittle it down by selecting the one id for a reseller: 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 ? Bradley Miller Arial1313,0000,FFFFNUVIO CORPORATIONArial Phone: 816-444-4422 ext. 6757 Fax: 913-498-1810 0000,0000,FFFFhttp://www.nuvio.com 0000,0000,FFFFbmiller@nuvio.com --Apple-Mail-24-1072725886--