Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id A66E09FB5D9 for ; Wed, 10 Oct 2007 15:20:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 38742-02-6 for ; Wed, 10 Oct 2007 15:20:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from n126.sc0.he.tucows.com (smtpout1089.sc0.he.tucows.com [64.97.144.89]) by postgresql.org (Postfix) with ESMTP id EFE079FB51D for ; Wed, 10 Oct 2007 15:20:03 -0300 (ADT) Received: from dreamland (74.94.66.41) by n126.sc0.he.tucows.com (7.2.069.1) (authenticated as ray@madigans.org) id 470C797E0001EAB6 for pgsql-sql@postgresql.org; Wed, 10 Oct 2007 18:20:00 +0000 From: "Ray Madigan" To: "Pgsql-Sql" Subject: Re: Computed table name in function Date: Wed, 10 Oct 2007 11:19:58 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1914 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/51 X-Sequence-Number: 29423 I thought that the documentation said I couldn't use EXECUTE on a SELECT INTO? -----Original Message----- From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org]On Behalf Of Scott Marlowe Sent: Wednesday, October 10, 2007 11:10 AM To: Ray Madigan Cc: Pgsql-Sql Subject: Re: [SQL] Computed table name in function On 10/10/07, Ray Madigan wrote: > I have a problem that I don't know where to look to understand the problem. > > I have a function that I first select to get a table name followed by > another select into on that table name. If someone could tell me where to > look to solve this problem I would appreciate it. > > It is something like > > DECLARE rec1 Record; > rec2 Record; > > SELECT aName INTO rec1 FROM tableA WHERE new.xxx = ?; > > IF FOUND THEN > > SELECT * INTO rec2 FROM rec1.aName where new.xxx = ?; You have to build your query as a string then use execute on it. ---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate