Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 1DEF49FB668 for ; Wed, 10 Oct 2007 15:10:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 13680-03 for ; Wed, 10 Oct 2007 15:10:06 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.172]) by postgresql.org (Postfix) with ESMTP id 8055E9FB572 for ; Wed, 10 Oct 2007 15:10:05 -0300 (ADT) Received: by ug-out-1314.google.com with SMTP id j3so321980ugf for ; Wed, 10 Oct 2007 11:10:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=ujqlm2eHDnDofkylHlF5MX1C10Jk0gbfKzdNRWExhEs=; b=WalpeFGwzHCCJkEeSrHszeJKjoWIkNs8otRfk8QROcSirCiCuJI7ui0m/UZvKXuXAzC0lV0py+YGt+mGJ17U18enawiUCAwigocTa53dKK0astUY2gRowDSNVP8rK0/ruG5PaB1irZc/LwDDdACMe1mHIqN07xK8VLtu3iUYOQY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=LCe6EbwLejRicJT2i1s4Q+PeYU/dX+gkVak9Zu8Qp5fRB5ev1fQCbH809xLQ+R44zYcM5zMdWuGjcu2V4b4K3fYR+OmuLTHDeCuw3gOFM1rB1m7k2KfI0J/NMqITQ43UrAgBI4qNQBSQ9cAOHPoLouPYl4vDlE6C6JqxPVi3iiI= Received: by 10.67.28.4 with SMTP id f4mr2213499ugj.1192039802786; Wed, 10 Oct 2007 11:10:02 -0700 (PDT) Received: by 10.67.29.6 with HTTP; Wed, 10 Oct 2007 11:10:02 -0700 (PDT) Message-ID: Date: Wed, 10 Oct 2007 13:10:02 -0500 From: "Scott Marlowe" To: "Ray Madigan" Subject: Re: Computed table name in function Cc: Pgsql-Sql In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/50 X-Sequence-Number: 29422 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.