Re: Rule Error - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Rule Error
Date
Msg-id 4704E244.3070402@archonet.com
Whole thread Raw
In response to Rule Error  ("Hengky Lie" <hengkyliwandouw@gmail.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "Hengky Lie"
Date:
Subject: Rule Error
Next
From: "Bart Degryse"
Date:
Subject: Re: Rule Error