Re: Rule Error

From: "Bart Degryse" <Bart(dot)Degryse(at)indicator(dot)be>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Rule Error
Date: 2007-10-04 12:57:03
Message-ID: 4704FF3F.A3DD.0030.0@indicator.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

You have defined the fields KODEGL and NAMAREK as uppercased field names.
In your rule you refer to an unquoted field KODEGL twice and twice to an unquoted field NAMAREK.
Default behaviour of PostgreSQL for unquoted fieldnames is to lowercase them.
As such these fields effectively don't exist in your tables.
Try

CREATE RULE "rule1" AS ON INSERT TO "public"."tblmasdbt"
DO (insert into tblmasgl ("KODEGL","NAMAREK") VALUES (new."KODEGL", new."NAMAREK"));
>>> "Hengky Lie" <hengkyliwandouw(at)gmail(dot)com> 2007-10-04 13:22 >>>

Dear Friends,

I have problem with rule and tried several times to solve it but not yet success. Hope someone can help me.

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.

So I create rule like this

--------------- SQL ---------------
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 MESSAGE ----------

ERROR: column "kodegl" of relation "tblmasgl" does not exist


Here is the Table Structure
---------------------------

CREATE TABLE "public"."tblmasgl" (
"KODEGL" VARCHAR(15) NOT NULL,
"NAMAREK" VARCHAR(50),
"GOLONGAN" VARCHAR(10),
"AWAL" DOUBLE PRECISION DEFAULT 0,
"Operator" VARCHAR(3),
CONSTRAINT "tblmasgl_pkey" PRIMARY KEY("KODEGL"),
CONSTRAINT "tblmasgl_fk" FOREIGN KEY ("KODEGL")
REFERENCES "public"."tbltragl"("KODEGL")
ON DELETE CASCADE
ON UPDATE NO ACTION
NOT DEFERRABLE
) WITHOUT OIDS;



CREATE TABLE "public"."tblmasdbt" (
"KODEGL" VARCHAR(15) NOT NULL,
"NAMAREK" VARCHAR(50),
"ALAMAT" VARCHAR(75),
"Telp" VARCHAR(50),
"Facs" VARCHAR(50),
"KOTA" VARCHAR(30),
"HP" VARCHAR(20),
"Plafond" DOUBLE PRECISION DEFAULT 0,
"Operator" VARCHAR(3),
"SALDOAWAL" DOUBLE PRECISION DEFAULT 0,
CONSTRAINT "tblmasdbt_pkey" PRIMARY KEY("KODEGL")
) WITHOUT OIDS;


Hope someone could help me. Thanks a lot

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 A. Kretschmer 2007-10-04 13:00:11 Re: Rule Error
Previous Message Richard Huxton 2007-10-04 12:53:24 Re: Rule Error