Re: Rule Error

From: Richard Huxton <dev(at)archonet(dot)com>
To: Hengky Lie <hengkyliwandouw(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Rule Error
Date: 2007-10-04 12:53:24
Message-ID: 4704E244.3070402@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

  • Rule Error at 2007-10-04 11:22:32 from Hengky Lie

Browse pgsql-sql by date

  From Date Subject
Next Message Bart Degryse 2007-10-04 12:57:03 Re: Rule Error
Previous Message Hengky Lie 2007-10-04 11:22:32 Rule Error