Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 6C17A2E425D for ; Tue, 5 Feb 2008 06:11:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 34791-01 for ; Tue, 5 Feb 2008 06:10:54 -0400 (AST) Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by postgresql.org (Postfix) with ESMTP id 5F2C22E3E65 for ; Tue, 5 Feb 2008 05:32:54 -0400 (AST) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by ptb-relay03.plus.net with esmtp (Exim) id 1JMKAd-00039N-Ev; Tue, 05 Feb 2008 09:32:51 +0000 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 39E99274061; Tue, 5 Feb 2008 09:32:50 +0000 (GMT) Message-ID: <47A82D42.8070007@archonet.com> Date: Tue, 05 Feb 2008 09:32:50 +0000 From: Richard Huxton User-Agent: Thunderbird 2.0.0.9 (X11/20071031) MIME-Version: 1.0 To: Tiziano Slack CC: pgsql-sql@postgresql.org Subject: Re: TG_TABLE_NAME as identifier References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Plusnet-Relay: 952428a8335f90158d252570fd9d1c20 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/15 X-Sequence-Number: 30106 Tiziano Slack wrote: > Hello everybody! I'm newbie to plpgsql syntax. Can anyone tell where > I'm getting wrong? > INSERT INTO TG_TABLE_NAME SELECT NEW.*; If you need to build a dynamic query with plpgsql you'll need to assemble it as a string and use EXECUTE. You can use variables in comparisons etc. but not as column-names or table-names. You might want to look at pltcl or plperl etc. if you are going to be doing a lot of this sort of stuff. -- Richard Huxton Archonet Ltd