Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 70A729F95E4 for ; Thu, 4 Oct 2007 09:53:39 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 18228-09 for ; Thu, 4 Oct 2007 09:53:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from ptb-relay03.plus.net (ptb-relay03.plus.net [212.159.14.214]) by postgresql.org (Postfix) with ESMTP id 969869F95AC for ; Thu, 4 Oct 2007 09:53:29 -0300 (ADT) Received: from [84.51.143.99] (helo=server3.office.archonet.com) by ptb-relay03.plus.net with esmtp (Exim) id 1IdQCi-0008Hz-PA; Thu, 04 Oct 2007 13:53:24 +0100 Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id 6DF3027408E; Thu, 4 Oct 2007 13:53:24 +0100 (BST) Message-ID: <4704E244.3070402@archonet.com> Date: Thu, 04 Oct 2007 13:53:24 +0100 From: Richard Huxton User-Agent: Thunderbird 2.0.0.6 (X11/20070728) MIME-Version: 1.0 To: Hengky Lie CC: pgsql-sql@postgresql.org Subject: Re: Rule Error References: <008f01c80678$de562990$6f00a8c0@hengky> In-Reply-To: <008f01c80678$de562990$6f00a8c0@hengky> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/22 X-Sequence-Number: 29394 Hengky Lie wrote: > > I have 2 tables : tblmasdbt and tblmasgl. > > I want on every record insertion in tblmasdbt, that record also > automatically insert into tblmasdbt. I need only 2 related field. You probably want triggers rather than rules, but anyway. > CREATE RULE "rule1" AS ON INSERT TO "public"."tblmasdbt" > DO (insert into tblmasgl (KODEGL,NAMAREK) VALUES (new.KODEGL, new.NAMAREK)); > But I always get this error : > > ERROR: column "kodegl" of relation "tblmasgl" does not exist There is not a column called kodegl on table tblmasgl. > Here is the Table Structure > CREATE TABLE "public"."tblmasgl" ( > "KODEGL" VARCHAR(15) NOT NULL, There you go - you double-quoted the column-name when creating the table. That means that it is literally "KODEGL" and will not match kodegl or KoDeGl or any other combination of upper and lower case. If you double-quote column-names when you create a table you'll want to double-quote them every time you use them too. -- Richard Huxton Archonet Ltd