Re: Rule Error - Mailing list pgsql-sql

From Bart Degryse
Subject Re: Rule Error
Date
Msg-id 4704FF3F.A3DD.0030.0@indicator.be
Whole thread Raw
In response to Rule Error  ("Hengky Lie" <hengkyliwandouw@gmail.com>)
List pgsql-sql
st1\:*{behavior:url(#default#ieooui) } 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@gmail.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

pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Rule Error
Next
From: "A. Kretschmer"
Date:
Subject: Re: Rule Error